Change property name prefix from 'slice.*' to 'openjpa.slice.*' + Apache License Header

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@619263 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Pinaki Poddar 2008-02-07 04:51:08 +00:00
parent fd7eae6210
commit c61d81ade6
17 changed files with 195 additions and 196 deletions

View File

@ -20,18 +20,13 @@ package org.apache.openjpa.slice;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.apache.openjpa.event.RemoteCommitEventManager;
import org.apache.openjpa.event.RemoteCommitProvider;
import org.apache.openjpa.lib.conf.Configuration;
import org.apache.openjpa.lib.conf.Configurations;
import org.apache.openjpa.lib.conf.PluginValue;

View File

@ -41,7 +41,7 @@ public class ProductDerivation extends AbstractProductDerivation implements
}
public String getConfigurationPrefix() {
return "slice";
return "openjpa.slice";
}
public int getType() {

View File

@ -1,55 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.slice;
import java.io.InputStream;
import java.util.Properties;
public class SliceVersion {
public static final String VERSION;
public static final String REVISION;
static {
Properties revisionProps = new Properties();
try {
InputStream in = SliceVersion.class.getResourceAsStream
("/META-INF/org.apache.openjpa.slice.revision.properties");
if (in != null) {
try {
revisionProps.load(in);
} finally {
in.close();
}
}
} catch (Exception e) {
}
VERSION = revisionProps.getProperty("slice.version", "0.0.0");
REVISION = revisionProps.getProperty("revision.number");
}
public static void main(String[] args) {
System.out.println(new SliceVersion());
}
public String toString() {
return "Slice Version " + VERSION + " [revision "+REVISION+"]";
}
}

View File

@ -1,120 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.slice.jdbc;
import org.apache.openjpa.kernel.StoreQuery;
import org.apache.openjpa.kernel.exps.QueryExpressions;
import org.apache.openjpa.kernel.exps.Value;
import org.apache.openjpa.lib.rop.ResultObjectProvider;
import org.apache.openjpa.util.InternalException;
public class AggregateResultObjectProvider implements ResultObjectProvider {
private final ResultObjectProvider[] _rops;
private final StoreQuery _query;
private final QueryExpressions[] _exps;
private Object _single;
private boolean _opened;
public AggregateResultObjectProvider(ResultObjectProvider[] rops,
StoreQuery q, QueryExpressions[] exps) {
_rops = rops;
_query = q;
_exps = exps;
}
public boolean absolute(int pos) throws Exception {
return false;
}
public void close() throws Exception {
_opened = false;
for (ResultObjectProvider rop:_rops)
rop.close();
}
public Object getResultObject() throws Exception {
if (!_opened)
throw new InternalException(this + " not-open");
return _single;
}
public void handleCheckedException(Exception e) {
_rops[0].handleCheckedException(e);
}
public boolean next() throws Exception {
if (!_opened) {
open();
}
if (_single != null)
return false;
Value[] values = _exps[0].projections;
Object[] single = new Object[values.length];
for (int i=0; i<values.length; i++) {
Value v = values[i];
boolean isAggregate = v.isAggregate();
int op = decideOperationType(v);
for (ResultObjectProvider rop:_rops) {
rop.next();
Object[] row = (Object[]) rop.getResultObject();
switch (op) {
case 2: single[i] = count(single[i],row[i]);
break;
default : single[i] = row[i];
}
}
}
_single = single;
return true;
}
int decideOperationType(Value v) {
String cls = v.getClass().getName();
if (cls.equals("org.apache.openjpa.jdbc.kernel.exps.Sum"))
return 1;
if (cls.equals("org.apache.openjpa.jdbc.kernel.exps.Count"))
return 2;
return 0;
}
long count(Object current, Object other) {
if (current == null)
return (Long) other;
return (Long)current + (Long)other;
}
public void open() throws Exception {
for (ResultObjectProvider rop:_rops)
rop.open();
_opened = true;
}
public void reset() throws Exception {
}
public int size() throws Exception {
return 1;
}
public boolean supportsRandomAccess() {
return false;
}
}

View File

@ -27,7 +27,6 @@ import org.apache.openjpa.kernel.Bootstrap;
import org.apache.openjpa.kernel.StoreManager;
import org.apache.openjpa.lib.conf.ConfigurationProvider;
import org.apache.openjpa.lib.util.Localizer;
import org.apache.openjpa.slice.SliceVersion;
/**
* A factory for distributed JDBC datastores.
@ -102,6 +101,6 @@ public class DistributedJDBCBrokerFactory extends JDBCBrokerFactory {
@Override
protected Object getFactoryInitializationBanner() {
return _loc.get("factory-init", new SliceVersion());
return _loc.get("factory-init", OpenJPAVersion.VERSION_NUMBER);
}
}

View File

@ -37,6 +37,7 @@ import org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl;
import org.apache.openjpa.jdbc.schema.DataSourceFactory;
import org.apache.openjpa.lib.conf.BooleanValue;
import org.apache.openjpa.lib.conf.ConfigurationProvider;
import org.apache.openjpa.lib.conf.Configurations;
import org.apache.openjpa.lib.conf.PluginValue;
import org.apache.openjpa.lib.conf.StringListValue;
import org.apache.openjpa.lib.conf.StringValue;
@ -50,7 +51,6 @@ import org.apache.openjpa.slice.DistributedBrokerImpl;
import org.apache.openjpa.slice.DistributionPolicy;
import org.apache.openjpa.slice.ExecutorServiceValue;
import org.apache.openjpa.slice.Slice;
import org.apache.openjpa.slice.SliceVersion;
import org.apache.openjpa.util.UserException;
/**
@ -74,10 +74,12 @@ public class DistributedJDBCConfigurationImpl extends JDBCConfigurationImpl
protected ExecutorServiceValue executorServicePlugin;
protected PluginValue distributionPolicyPlugin;
public static final String PREFIX_SLICE = "openjpa.slice.";
public static final String PREFIX_OPENJPA = "openjpa.";
public static final String REGEX_DOT = "\\.";
public static final String DOT = ".";
private static Localizer _loc =
Localizer.forPackage(DistributedJDBCConfigurationImpl.class);
public static final String PREFIX_SLICE = "slice.";
public static final String PREFIX_OPENJPA = "openjpa.";
/**
* Configure itself as well as underlying slices.
@ -89,7 +91,6 @@ public class DistributedJDBCConfigurationImpl extends JDBCConfigurationImpl
String pUnit = getPersistenceUnitName(p);
setDiagnosticContext(pUnit);
Log log = getConfigurationLog();
log.info(_loc.get("config-init", SliceVersion.VERSION));
brokerPlugin.setString(DistributedBrokerImpl.class.getName());
@ -188,6 +189,8 @@ public class DistributedJDBCConfigurationImpl extends JDBCConfigurationImpl
public DistributionPolicy getDistributionPolicyInstance() {
if (distributionPolicyPlugin.get() == null) {
// Configurations.getProperty(distributionPolicyPlugin.getProperty(), m)
// distributionPolicyPlugin.setString(toProperties(false).get(key))
distributionPolicyPlugin.instantiate(DistributionPolicy.class,
this, true);
}
@ -366,9 +369,9 @@ public class DistributedJDBCConfigurationImpl extends JDBCConfigurationImpl
List<String> sliceNames = new ArrayList<String>();
for (Object o : p.keySet()) {
String key = o.toString();
if (key.startsWith(PREFIX_SLICE) && key.split("\\.").length > 2) {
if (key.startsWith(PREFIX_SLICE) && getPartCount(key) > 3) {
String sliceName =
chopTail(chopHead(o.toString(), PREFIX_SLICE), ".");
chopTail(chopHead(o.toString(), PREFIX_SLICE), DOT);
if (!sliceNames.contains(sliceName))
sliceNames.add(sliceName);
}
@ -376,6 +379,10 @@ public class DistributedJDBCConfigurationImpl extends JDBCConfigurationImpl
return sliceNames;
}
static int getPartCount(String s) {
return (s == null) ? 0 : s.split(REGEX_DOT).length;
}
static String chopHead(String s, String head) {
if (s.startsWith(head))
return s.substring(head.length());
@ -407,7 +414,7 @@ public class DistributedJDBCConfigurationImpl extends JDBCConfigurationImpl
*/
Map createSliceProperties(Map original, String slice) {
Map result = new Properties();
String prefix = PREFIX_SLICE + slice + ".";
String prefix = PREFIX_SLICE + slice + DOT;
for (Object o : original.keySet()) {
String key = o.toString();
if (key.startsWith(prefix)) {
@ -476,5 +483,4 @@ public class DistributedJDBCConfigurationImpl extends JDBCConfigurationImpl
}
return (ExecutorService) executorServicePlugin.get();
}
}

View File

@ -24,7 +24,6 @@ import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.apache.openjpa.jdbc.kernel.JDBCStore;
@ -137,8 +136,8 @@ class DistributedStoreQuery extends JDBCStoreQuery {
boolean isAscending = ascending.length > 0;
boolean isUnique = q.getContext().isUnique();
if (isUnique) {
return new UniqueResultObjectProvider(tmp, q, getQueryExpressions());
return new UniqueResultObjectProvider(tmp, q,
getQueryExpressions());
}
if (isAscending) {
return new OrderingMergedResultObjectProvider(tmp, ascending,

View File

@ -1,3 +1,21 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.slice.jdbc;
import org.apache.openjpa.kernel.StoreQuery;

View File

@ -1,3 +1,21 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<HTML>
<BODY>
Implements Distributed version of JDBCStoreManager and JDBCStoreQuery.

View File

@ -1,3 +1,21 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<HTML>
<BODY>
Extended OpenJPA Interfaces for distributed databases.

View File

@ -1,3 +1,21 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.slice.transaction;
import java.util.Collections;

View File

@ -1,3 +1,21 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.slice.transaction;
import java.util.Collections;

View File

@ -1,3 +1,21 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.slice.transaction;
import java.util.Set;

View File

@ -1,3 +1,21 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<HTML>
<BODY>
Implements TransactionManager to manage transactions across the database

View File

@ -1,3 +1,20 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
slice-not-found: No slice named "{0}" can be found. Available slices are "{1}"
slice-no-url: Slice "{0}" has no database URL. Specify a valid database URL \
as the value of "slice.{0}.ConnectionURL" property. ConnectionURL is the \
@ -31,7 +48,7 @@ slice-xa-disabled: Not all active slices "{0}" is XA-complaint and hence store \
global transaction but otherwise the atomic nature of commit across all \
slices is not guaranteed.
two-phase: "{3}".{0}"(xid=[{4}]] Connection={1} XAConnection={2}
factory-init: Starting {0}
factory-init: Starting OpenJPA Slice {0}
config-init: Configuring Slice {0}
no-slice-names: Slice identifiers are not listed in [slice.Names] property. \
The configuration will be scanned to determine slice identifiers.

View File

@ -1,3 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
bad-policy-slice:Distribution policy "{0}" has returned invalid slice \
"{1}" for "{2}". The valid slices are {3}. This error may happen \
when one or more of the originally configured slices are unavailable \

View File

@ -1,3 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
no-txn-on-thread: No transaction is associated with current thread "{0}"
prepare-failed: one or more XA-complaint resources have failed to prepare for \
commit during the first phase of a two-phase commit protocol.