index int64 0 0 | repo_id stringlengths 9 205 | file_path stringlengths 31 246 | content stringlengths 1 12.2M | __index_level_0__ int64 0 10k |
|---|---|---|---|---|
0 | Create_ds/aries/ejb/openejb-extender-itest/src/test/java/beans | Create_ds/aries/ejb/openejb-extender-itest/src/test/java/beans/integration/Tx.java | /**
* 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 beans.integration;
import javax.ejb.Local;
@Local
public interface Tx {
public Object getNoTransactionId() throws Exception;
public Object getMaybeTransactionId() throws Exception;
public Object getTransactionId() throws Exception;
public Object getNewTransactionId() throws Exception;
}
| 9,000 |
0 | Create_ds/aries/ejb/openejb-extender-itest/src/test/java/beans/integration | Create_ds/aries/ejb/openejb-extender-itest/src/test/java/beans/integration/impl/TxSingleton.java | /**
* 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 beans.integration.impl;
import javax.ejb.Singleton;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.naming.InitialContext;
import javax.transaction.TransactionSynchronizationRegistry;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import beans.integration.Tx;
@Singleton
public class TxSingleton implements Tx {
private TransactionSynchronizationRegistry getTSR() {
BundleContext ctx = FrameworkUtil.getBundle(TxSingleton.class).getBundleContext();
return (TransactionSynchronizationRegistry) ctx.getService(
ctx.getServiceReference("javax.transaction.TransactionSynchronizationRegistry"));
}
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public Object getNoTransactionId() throws Exception {
return getTSR().getTransactionKey();
}
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
public Object getMaybeTransactionId() throws Exception {
return getTSR().getTransactionKey();
}
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public Object getTransactionId() throws Exception {
return getTSR().getTransactionKey();
}
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public Object getNewTransactionId() throws Exception {
return getTSR().getTransactionKey();
}
}
| 9,001 |
0 | Create_ds/aries/ejb/openejb-extender-itest/src/test/java/beans/integration | Create_ds/aries/ejb/openejb-extender-itest/src/test/java/beans/integration/impl/JPASingleton.java | /**
* 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 beans.integration.impl;
import javax.ejb.Singleton;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import beans.jpa.Laptop;
@Singleton
public class JPASingleton {
@PersistenceContext(unitName="ejb-test")
private EntityManager em;
public void editEntity(String serial) {
Laptop l = em.find(Laptop.class, serial);
l.setHardDiskSize(Integer.MAX_VALUE);
l.setNumberOfCores(4);
}
}
| 9,002 |
0 | Create_ds/aries/ejb/openejb-extender-itest/src/test/java/beans | Create_ds/aries/ejb/openejb-extender-itest/src/test/java/beans/jpa/Laptop.java | /**
* 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 beans.jpa;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class Laptop {
@Id
private String serialNumber;
private int numberOfCores;
private int hardDiskSize;
public String getSerialNumber() {
return serialNumber;
}
public void setSerialNumber(String serialNumber) {
this.serialNumber = serialNumber;
}
public int getNumberOfCores() {
return numberOfCores;
}
public void setNumberOfCores(int numberOfCores) {
this.numberOfCores = numberOfCores;
}
public int getHardDiskSize() {
return hardDiskSize;
}
public void setHardDiskSize(int hardDiskSize) {
this.hardDiskSize = hardDiskSize;
}
}
| 9,003 |
0 | Create_ds/aries/ejb/openejb-extender-itest/src/test/java/beans | Create_ds/aries/ejb/openejb-extender-itest/src/test/java/beans/xml/LocalIface.java | /**
* 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 beans.xml;
public interface LocalIface {
public String getLocalString();
}
| 9,004 |
0 | Create_ds/aries/ejb/openejb-extender-itest/src/test/java/beans | Create_ds/aries/ejb/openejb-extender-itest/src/test/java/beans/xml/RemoteIface.java | /**
* 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 beans.xml;
public interface RemoteIface {
public String getRemoteString();
}
| 9,005 |
0 | Create_ds/aries/ejb/openejb-extender-itest/src/test/java/beans | Create_ds/aries/ejb/openejb-extender-itest/src/test/java/beans/xml/XMLBean.java | /**
* 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 beans.xml;
public class XMLBean implements LocalIface, RemoteIface {
public String getRemoteString() {
return "A Remote Call";
}
public String getLocalString() {
return "A Local Call";
}
}
| 9,006 |
0 | Create_ds/aries/ejb/ejb-modeller/src/test/java/test | Create_ds/aries/ejb/ejb-modeller/src/test/java/test/ejbs/StatefulSessionBean.java | /**
* 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 test.ejbs;
import javax.ejb.Stateful;
@Stateful(name="Stateful")
public class StatefulSessionBean {
}
| 9,007 |
0 | Create_ds/aries/ejb/ejb-modeller/src/test/java/test | Create_ds/aries/ejb/ejb-modeller/src/test/java/test/ejbs/StatelessSessionBean.java | /**
* 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 test.ejbs;
import javax.ejb.Stateless;
@Stateless(name="Annotated")
public class StatelessSessionBean {
}
| 9,008 |
0 | Create_ds/aries/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling | Create_ds/aries/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBLocatorFactoryTest.java | /**
* 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.aries.ejb.modelling.impl;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.apache.aries.ejb.modelling.EJBLocator;
import org.apache.aries.util.io.IOUtils;
import org.junit.Test;
public class EJBLocatorFactoryTest {
@Test
public void testGetEJBLocator() {
EJBLocator locator = EJBLocatorFactory.getEJBLocator();
assertNotNull(locator);
assertTrue(locator.getClass().getName(), locator instanceof OpenEJBLocator);
}
@Test
public void testGetEJBLocatorNoOpenEJB() throws Exception {
Class<?> elf = new ClassLoader(getClass().getClassLoader()) {
@Override
public Class<?> loadClass(String className) throws ClassNotFoundException {
if(className.startsWith("org.apache.openejb"))
throw new ClassNotFoundException(className);
if(className.equals(EJBLocatorFactory.class.getName())) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
IOUtils.copy(getResourceAsStream(className.replace('.', '/') + ".class"), baos);
} catch (IOException e) {
throw new ClassNotFoundException(className, e);
}
return defineClass(className, baos.toByteArray(), 0, baos.size());
}
return super.loadClass(className);
}
}.loadClass(EJBLocatorFactory.class.getName());
EJBLocator locator = (EJBLocator) elf.getMethod("getEJBLocator").invoke(null);
assertNotNull(locator);
assertTrue(locator.getClass().getName(), locator instanceof EJBLocationUnavailable);
}
}
| 9,009 |
0 | Create_ds/aries/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling | Create_ds/aries/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBModellerTest.java | /**
* 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.aries.ejb.modelling.impl;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import org.apache.aries.application.modelling.ModellerException;
import org.apache.aries.ejb.modelling.EJBLocator;
import org.apache.aries.unittest.mocks.MethodCall;
import org.apache.aries.unittest.mocks.Skeleton;
import org.apache.aries.util.filesystem.IDirectory;
import org.apache.aries.util.manifest.BundleManifest;
import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.Constants;
public class EJBModellerTest {
private EJBModeller modeller;
private Skeleton ejbLocator;
private IDirectory bundleLocation;
@Before
public void setup() {
modeller = new EJBModeller();
EJBLocator locator = Skeleton.newMock(EJBLocator.class);
modeller.setLocator(locator);
ejbLocator = Skeleton.getSkeleton(locator);
bundleLocation = Skeleton.newMock(IDirectory.class);
}
@Test
public void testModelServicesNoExportEJB() throws ModellerException {
Manifest man = new Manifest();
setBasicHeaders(man);
modeller.modelServices(new BundleManifest(man), bundleLocation);
ejbLocator.assertSkeletonNotCalled();
}
@Test
public void testModelServicesEmptyExportEJB() throws ModellerException {
Manifest man = new Manifest();
setBasicHeaders(man);
man.getMainAttributes().putValue("Export-EJB", "");
modeller.modelServices(new BundleManifest(man), bundleLocation);
ejbLocator.assertCalled(new MethodCall(EJBLocator.class, "findEJBs", BundleManifest.class,
bundleLocation, ParsedEJBServices.class));
}
@Test
public void testModelServicesNoneExportEJB() throws ModellerException {
Manifest man = new Manifest();
setBasicHeaders(man);
man.getMainAttributes().putValue("Export-EJB", "NONE,anEJB , another");
modeller.modelServices(new BundleManifest(man), bundleLocation);
ejbLocator.assertSkeletonNotCalled();
}
@Test
public void testModelServicesExportEJB() throws ModellerException {
Manifest man = new Manifest();
setBasicHeaders(man);
man.getMainAttributes().putValue("Export-EJB", "anEJB , another");
modeller.modelServices(new BundleManifest(man), bundleLocation);
ejbLocator.assertCalled(new MethodCall(EJBLocator.class, "findEJBs", BundleManifest.class,
bundleLocation, ParsedEJBServices.class));
}
private void setBasicHeaders(Manifest man) {
Attributes att = man.getMainAttributes();
att.putValue(Constants.BUNDLE_MANIFESTVERSION, "2");
att.putValue(Constants.BUNDLE_SYMBOLICNAME, "testBundle");
}
}
| 9,010 |
0 | Create_ds/aries/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling | Create_ds/aries/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBLocatorTest.java | /**
* 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.aries.ejb.modelling.impl;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import org.apache.aries.application.modelling.ModellerException;
import org.apache.aries.ejb.modelling.EJBRegistry;
import org.apache.aries.unittest.mocks.MethodCall;
import org.apache.aries.unittest.mocks.Skeleton;
import org.apache.aries.util.filesystem.FileSystem;
import org.apache.aries.util.filesystem.ICloseableDirectory;
import org.apache.aries.util.io.IOUtils;
import org.apache.aries.util.manifest.BundleManifest;
import org.junit.Before;
import org.junit.Test;
public class EJBLocatorTest {
private EJBRegistry registry;
@Before
public void setup() {
registry = Skeleton.newMock(EJBRegistry.class);
}
@Test(expected=ModellerException.class)
public void testUnavailable() throws ModellerException {
new EJBLocationUnavailable().findEJBs(null, null, null);
}
@Test
public void testEJBJARInZip() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
zos.close();
runTest(baos.toByteArray(), "MANIFEST_1.MF");
assertXML(true);
assertAnnotation(false);
}
@Test
public void testEJBJARAndAnnotatedInZip() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
addToZip(zos, "test/ejbs/StatelessSessionBean.class");
addToZip(zos, "test/ejbs/StatefulSessionBean.class");
zos.close();
runTest(baos.toByteArray(), "MANIFEST_1.MF");
assertXML(true);
assertAnnotation(true);
}
@Test
public void testAnnotatedOnlyInZip() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "test/ejbs/StatelessSessionBean.class");
addToZip(zos, "test/ejbs/StatefulSessionBean.class");
zos.close();
runTest(baos.toByteArray(), "MANIFEST_1.MF");
assertXML(false);
assertAnnotation(true);
}
@Test
public void testEJBJARAndAnnotatedNotOnClasspathInZip() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
addToZip(zos, "test/ejbs/StatelessSessionBean.class", "no/test/ejb/StatelessSessionBean.class");
addToZip(zos, "test/ejbs/StatefulSessionBean.class", "no/test/ejb/StatefulSessionBean.class");
zos.close();
runTest(baos.toByteArray(), "MANIFEST_2.MF");
assertXML(true);
assertAnnotation(false);
}
@Test
public void testEJBJARAndAnnotatedOnClasspathInZip() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
addToZip(zos, "test/ejbs/StatelessSessionBean.class", "yes/test/ejb/StatelessSessionBean.class");
addToZip(zos, "test/ejbs/StatefulSessionBean.class", "yes/test/ejb/StatefulSessionBean.class");
zos.close();
runTest(baos.toByteArray(), "MANIFEST_2.MF");
assertXML(true);
assertAnnotation(true);
}
@Test
public void testEJBJARInWebZip() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "ejb-jar.xml", "WEB-INF/ejb-jar.xml");
zos.close();
runTest(baos.toByteArray(), "MANIFEST_3.MF");
assertXML(true);
assertAnnotation(false);
}
@Test
public void testEJBJARInWrongPlaceWebZip() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
zos.close();
runTest(baos.toByteArray(), "MANIFEST_3.MF");
assertXML(false);
assertAnnotation(false);
}
@Test
public void testEJBJARAndAnnotatedInWebZip() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "ejb-jar.xml", "WEB-INF/ejb-jar.xml");
addToZip(zos, "test/ejbs/StatelessSessionBean.class");
addToZip(zos, "test/ejbs/StatefulSessionBean.class");
zos.close();
runTest(baos.toByteArray(), "MANIFEST_3.MF");
assertXML(true);
assertAnnotation(true);
}
@Test
public void testAnnotatedOnlyInWebZip() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "test/ejbs/StatelessSessionBean.class");
addToZip(zos, "test/ejbs/StatefulSessionBean.class");
zos.close();
runTest(baos.toByteArray(), "MANIFEST_3.MF");
assertXML(false);
assertAnnotation(true);
}
@Test
public void testEJBJARAndAnnotatedNotOnClasspathInWebZip() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "ejb-jar.xml", "WEB-INF/ejb-jar.xml");
addToZip(zos, "test/ejbs/StatelessSessionBean.class", "no/test/ejb/StatelessSessionBean.class");
addToZip(zos, "test/ejbs/StatefulSessionBean.class", "no/test/ejb/StatefulSessionBean.class");
zos.close();
runTest(baos.toByteArray(), "MANIFEST_4.MF");
assertXML(true);
assertAnnotation(false);
}
@Test
public void testEJBJARAndAnnotatedOnClasspathInWebZip() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "ejb-jar.xml", "WEB-INF/ejb-jar.xml");
addToZip(zos, "test/ejbs/StatelessSessionBean.class", "yes/test/ejb/StatelessSessionBean.class");
addToZip(zos, "test/ejbs/StatefulSessionBean.class", "yes/test/ejb/StatefulSessionBean.class");
zos.close();
runTest(baos.toByteArray(), "MANIFEST_4.MF");
assertXML(true);
assertAnnotation(true);
}
private void runTest(byte[] zip, String manifest) throws ModellerException,
IOException {
ICloseableDirectory icd = FileSystem.getFSRoot(new
ByteArrayInputStream(zip));
new OpenEJBLocator().findEJBs(new BundleManifest(getClass().getClassLoader().
getResourceAsStream(manifest)), icd, registry);
icd.close();
}
private void addToZip(ZipOutputStream zos, String src) throws IOException {
addToZip(zos, src, src);
}
private void addToZip(ZipOutputStream zos, String src, String outLocation) throws IOException {
zos.putNextEntry(new ZipEntry(outLocation));
IOUtils.copy(getClass().getClassLoader().
getResourceAsStream(src), zos);
zos.closeEntry();
}
private void assertXML(boolean b) {
Skeleton s = Skeleton.getSkeleton(registry);
MethodCall mc = new MethodCall(EJBRegistry.class, "addEJBView",
"XML", "SINGLETON", "local.Iface", false);
if(b)
s.assertCalledExactNumberOfTimes(mc, 1);
else
s.assertNotCalled(mc);
mc = new MethodCall(EJBRegistry.class, "addEJBView",
"XML", "SINGLETON", "remote.Iface", true);
if(b)
s.assertCalledExactNumberOfTimes(mc, 1);
else
s.assertNotCalled(mc);
}
private void assertAnnotation(boolean b) {
Skeleton s = Skeleton.getSkeleton(registry);
MethodCall mc = new MethodCall(EJBRegistry.class, "addEJBView",
"Annotated", "STATELESS", "test.ejbs.StatelessSessionBean", false);
if(b)
s.assertCalledExactNumberOfTimes(mc, 1);
else
s.assertNotCalled(mc);
mc = new MethodCall(EJBRegistry.class, "addEJBView",
String.class, "STATEFUL", String.class, boolean.class);
if(b)
s.assertCalledExactNumberOfTimes(mc, 1);
else
s.assertNotCalled(mc);
}
}
| 9,011 |
0 | Create_ds/aries/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling | Create_ds/aries/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/ParsedEJBServicesTest.java | /**
* 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.aries.ejb.modelling.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.Iterator;
import org.apache.aries.application.modelling.ModellerException;
import org.junit.Test;
public class ParsedEJBServicesTest {
@Test
public void testNoAllowedNames() throws ModellerException {
ParsedEJBServices pes = new ParsedEJBServices();
pes.addEJBView("Foo", "Stateless", "com.acme.Bar", false);
assertTrue(pes.getServices().isEmpty());
}
@Test
public void testNONE() throws ModellerException {
ParsedEJBServices pes = new ParsedEJBServices();
pes.setAllowedNames(Arrays.asList("NONE", "Foo"));
pes.addEJBView("Foo", "Stateless", "com.acme.Bar", false);
assertTrue(pes.getServices().isEmpty());
}
@Test
public void testEmpty() throws ModellerException {
ParsedEJBServices pes = new ParsedEJBServices();
pes.setAllowedNames(Arrays.asList(""));
pes.addEJBView("Foo", "Stateless", "com.acme.Bar", false);
pes.addEJBView("Baz", "Stateless", "com.acme.Bar", true);
assertEquals(2, pes.getServices().size());
Iterator it = pes.getServices().iterator();
assertEquals(new EJBServiceExport("Foo", "Stateless", "com.acme.Bar", false),
it.next());
assertEquals(new EJBServiceExport("Baz", "Stateless", "com.acme.Bar", true),
it.next());
}
@Test
public void testSome() throws ModellerException {
ParsedEJBServices pes = new ParsedEJBServices();
pes.setAllowedNames(Arrays.asList("Bar", "Baz"));
pes.addEJBView("Foo", "Stateless", "com.acme.Bar", false);
pes.addEJBView("Baz", "Stateless", "com.acme.Bar", true);
assertEquals(1, pes.getServices().size());
Iterator it = pes.getServices().iterator();
assertEquals(new EJBServiceExport("Baz", "Stateless", "com.acme.Bar", true),
it.next());
}
@Test
public void testStateful() throws ModellerException {
ParsedEJBServices pes = new ParsedEJBServices();
pes.setAllowedNames(Arrays.asList("Bar", "Baz"));
pes.addEJBView("Baz", "Stateful", "com.acme.Bar", true);
assertEquals(0, pes.getServices().size());
}
@Test
public void testCases() throws ModellerException {
ParsedEJBServices pes = new ParsedEJBServices();
pes.setAllowedNames(Arrays.asList("ALL", "Foo", " "));
pes.addEJBView("Foo", "STATELESS", "com.acme.Bar", false);
pes.addEJBView("Bar", "StAtElEsS", "com.acme.Bar", true);
pes.addEJBView("Baz", "stateless", "com.acme.Baz", true);
assertEquals(1, pes.getServices().size());
Iterator it = pes.getServices().iterator();
assertEquals(new EJBServiceExport("Foo", "Stateless", "com.acme.Bar", false),
it.next());
}
}
| 9,012 |
0 | Create_ds/aries/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb | Create_ds/aries/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/EJBRegistry.java | /**
* 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.aries.ejb.modelling;
/**
* A registry of located Session EJBs
*/
public interface EJBRegistry {
/**
* Add a view of a session EJB, e.g. a local home, remote business interface etc.
*
* @param ejbName The ejb name
* @param ejbType The ejb type (e.g. stateless)
* @param interfaceName The fully qualified Java type name for this view
* @param remote
*/
public void addEJBView(String ejbName, String ejbType, String interfaceName,
boolean remote);
}
| 9,013 |
0 | Create_ds/aries/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb | Create_ds/aries/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/EJBLocator.java | /**
* 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.aries.ejb.modelling;
import org.apache.aries.application.modelling.ModellerException;
import org.apache.aries.util.filesystem.IDirectory;
import org.apache.aries.util.manifest.BundleManifest;
/**
* A plug point for locating session EJBs in a bundle.
*/
public interface EJBLocator {
/**
* Find any session beans defined in the IDirectory bundle and register them
* with the supplied {@link EJBRegistry}.
*
* @param manifest The manifest for the bundle
* @param bundle The bundle binary
* @param registry The registry of located Session EJBs
* @throws ModellerException
*/
public void findEJBs(BundleManifest manifest, IDirectory bundle, EJBRegistry registry)
throws ModellerException;
}
| 9,014 |
0 | Create_ds/aries/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling | Create_ds/aries/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBModeller.java | /**
* 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.aries.ejb.modelling.impl;
import java.util.ArrayList;
import java.util.Collection;
import org.apache.aries.application.modelling.ModellerException;
import org.apache.aries.application.modelling.ParsedServiceElements;
import org.apache.aries.application.modelling.ServiceModeller;
import org.apache.aries.ejb.modelling.EJBLocator;
import org.apache.aries.util.filesystem.IDirectory;
import org.apache.aries.util.manifest.BundleManifest;
import org.apache.aries.util.manifest.ManifestHeaderProcessor;
import org.apache.aries.util.manifest.ManifestHeaderProcessor.NameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class EJBModeller implements ServiceModeller {
private static final Logger logger = LoggerFactory.getLogger(EJBModeller.class);
private EJBLocator locator;
public void setLocator(EJBLocator locator) {
this.locator = locator;
}
/**
* This modeller only searches for EJBs if there is an Export-EJB header with
* a value other than NONE (the default empty string value means ALL exported).
*/
public ParsedServiceElements modelServices(BundleManifest manifest, IDirectory bundle)
throws ModellerException {
logger.debug("modelServices", new Object[] {manifest, bundle});
ParsedEJBServices ejbServices = new ParsedEJBServices();
String header = manifest.getRawAttributes().getValue("Export-EJB");
logger.debug("Export-EJB header is " + header);
if(header == null)
return ejbServices;
Collection<String> allowedNames = getNames(header.trim());
if(allowedNames.contains("NONE"))
return ejbServices;
ejbServices.setAllowedNames(allowedNames);
locator.findEJBs(manifest, bundle, ejbServices);
logger.debug("ejbServices", ejbServices);
return ejbServices;
}
private Collection<String> getNames(String header) {
Collection<String> names = new ArrayList<String>();
for(NameValuePair nvp: ManifestHeaderProcessor.parseExportString(header)){
names.add(nvp.getName().trim());
}
return names;
}
}
| 9,015 |
0 | Create_ds/aries/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling | Create_ds/aries/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/StandaloneEJBModeller.java | /**
* 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.aries.ejb.modelling.impl;
/**
* An {@link EJBModeller} for use in standalone modelling
*/
public class StandaloneEJBModeller extends EJBModeller {
public StandaloneEJBModeller() {
setLocator(EJBLocatorFactory.getEJBLocator());
}
}
| 9,016 |
0 | Create_ds/aries/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling | Create_ds/aries/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBServiceExport.java | /**
* 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.aries.ejb.modelling.impl;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.apache.aries.application.modelling.ExportedService;
import org.apache.aries.application.modelling.ModellingConstants;
import org.apache.aries.application.modelling.ResourceType;
import org.apache.aries.application.modelling.WrappedServiceMetadata;
import org.apache.aries.application.utils.service.ExportedServiceHelper;
import org.osgi.framework.Constants;
/**
* This class represents the service exported on behalf of a Session Bean
*/
public class EJBServiceExport implements ExportedService {
private final String interfaceName;
private final String ejbName;
private final Map<String, Object> _attributes;
private final Map<String, Object> serviceProperties;
private String _toString;
/**
* Set up this {@link ExportedService} with the right EJB properties
* @param ejbName
* @param ejbType
* @param interfaceName
* @param remote
*/
public EJBServiceExport(String ejbName, String ejbType, String interfaceName,
boolean remote) {
this.interfaceName = interfaceName;
this.ejbName = ejbName;
serviceProperties = new HashMap<String, Object>();
serviceProperties.put("ejb.name", ejbName);
serviceProperties.put("ejb.type", correctCase(ejbType));
if(remote)
serviceProperties.put("service.exported.interfaces", interfaceName);
_attributes = new HashMap<String, Object>(serviceProperties);
_attributes.put(Constants.OBJECTCLASS, interfaceName);
_attributes.put (Constants.SERVICE_RANKING, "0");
_attributes.put(ModellingConstants.OBR_SERVICE, ModellingConstants.OBR_SERVICE);
}
/**
* The ejb.type property is always capitalised first letter, lowercase otherwise
* @param ejbType
* @return
*/
private String correctCase(String ejbType) {
String result = ejbType.substring(0, 1).toUpperCase();
result += ejbType.substring(1).toLowerCase();
return result;
}
public Map<String, Object> getAttributes() {
return _attributes;
}
public ResourceType getType() {
return ResourceType.SERVICE;
}
public Collection<String> getInterfaces() {
return Arrays.asList(interfaceName);
}
public String getName() {
return ejbName;
}
public int getRanking() {
return 0;
}
public Map<String, Object> getServiceProperties() {
return serviceProperties;
}
public int compareTo(WrappedServiceMetadata o) {
return ExportedServiceHelper.portableExportedServiceCompareTo(this, o);
}
@Override
public boolean equals (Object o) {
return ExportedServiceHelper.portableExportedServiceEquals(this, o);
}
@Override
public int hashCode() {
return ExportedServiceHelper.portableExportedServiceHashCode(this);
}
@Override
public String toString() {
if (_toString == null) {
_toString = ExportedServiceHelper.generatePortableExportedServiceToString(this);
}
return _toString;
}
public boolean identicalOrDiffersOnlyByName(WrappedServiceMetadata wsmi) {
return ExportedServiceHelper.
portableExportedServiceIdenticalOrDiffersOnlyByName(this, wsmi);
}
} | 9,017 |
0 | Create_ds/aries/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling | Create_ds/aries/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/IDirectoryFinder.java | /**
* 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.aries.ejb.modelling.impl;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import org.apache.aries.application.modelling.ModellerException;
import org.apache.aries.util.filesystem.IDirectory;
import org.apache.aries.util.filesystem.IFile;
import org.apache.aries.util.io.IOUtils;
import org.apache.xbean.finder.AbstractFinder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class IDirectoryFinder extends AbstractFinder {
private static final Logger logger = LoggerFactory.getLogger(IDirectoryFinder.class);
private final List<IDirectory> cpEntries;
private final ClassLoader loader;
public IDirectoryFinder(ClassLoader parent, List<IDirectory> cp) throws ModellerException {
cpEntries = cp;
loader = new ResourceClassLoader(parent, cpEntries);
for(IDirectory entry : cpEntries) {
for(IFile f : entry.listAllFiles()) {
if(f.getName().endsWith(".class")) {
try {
readClassDef(f.open());
} catch (Exception e) {
throw new ModellerException(e);
}
}
}
}
}
@Override
protected URL getResource(String arg0) {
return loader.getResource(arg0);
}
@Override
protected Class<?> loadClass(String arg0) throws ClassNotFoundException {
return loader.loadClass(arg0);
}
/**
* A ClassLoader used by OpenEJB in annotation scanning
*/
public static class ResourceClassLoader extends ClassLoader {
private final List<IDirectory> classpath;
public ResourceClassLoader(ClassLoader cl, List<IDirectory> cpEntries) {
super(cl);
classpath = cpEntries;
}
@Override
protected URL findResource(String resName) {
for(IDirectory id : classpath) {
IFile f = id.getFile(resName);
if(f != null)
try {
return f.toURL();
} catch (MalformedURLException e) {
logger.error("Error getting URL for file " + f, e);
}
}
return null;
}
@Override
protected Class<?> findClass(String className)
throws ClassNotFoundException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
InputStream is = getResourceAsStream(
className.replace('.', '/') + ".class");
if(is == null)
throw new ClassNotFoundException(className);
IOUtils.copy(is, baos);
return defineClass(className, baos.toByteArray(), 0, baos.size());
} catch (IOException e) {
throw new ClassNotFoundException(className, e);
}
}
}
}
| 9,018 |
0 | Create_ds/aries/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling | Create_ds/aries/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/ParsedEJBServices.java | /**
* 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.aries.ejb.modelling.impl;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.apache.aries.application.modelling.ExportedService;
import org.apache.aries.application.modelling.ImportedService;
import org.apache.aries.application.modelling.ParsedServiceElements;
import org.apache.aries.ejb.modelling.EJBRegistry;
/**
* An {@link EJBRegistry} that marks the {@link ParsedServiceElements} provided
* by the EJB bundle.
* @author Tim
*
*/
public class ParsedEJBServices implements ParsedServiceElements, EJBRegistry {
private final Collection<ImportedService> references;
private final Collection<ExportedService> services;
private boolean all;
private Set<String> allowedNames;
public ParsedEJBServices() {
this.references = Collections.emptyList();
this.services = new ArrayList<ExportedService>();
allowedNames = new HashSet<String>();
all = false;
}
public Collection<ImportedService> getReferences() {
return references;
}
public Collection<ExportedService> getServices() {
return Collections.unmodifiableCollection(services);
}
public void setAllowedNames(Collection<String> names) {
if(names.contains("NONE")) {
all= false;
allowedNames.clear();
return;
}
if(names.size() == 1 && "".equals(names.iterator().next())) {
all = true;
return;
}
allowedNames.addAll(names);
}
public void addEJBView(String ejbName, String ejbType, String interfaceName,
boolean remote) {
if(ejbType.equalsIgnoreCase("Stateful"))
return;
if(all || allowedNames.contains(ejbName))
services.add(new EJBServiceExport(ejbName, ejbType, interfaceName, remote));
}
}
| 9,019 |
0 | Create_ds/aries/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling | Create_ds/aries/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/OpenEJBLocator.java | /**
* 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.aries.ejb.modelling.impl;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.aries.application.modelling.ModellerException;
import org.apache.aries.ejb.modelling.EJBLocator;
import org.apache.aries.ejb.modelling.EJBRegistry;
import org.apache.aries.util.filesystem.ICloseableDirectory;
import org.apache.aries.util.filesystem.IDirectory;
import org.apache.aries.util.filesystem.IFile;
import org.apache.aries.util.manifest.BundleManifest;
import org.apache.aries.util.manifest.ManifestHeaderProcessor;
import org.apache.aries.util.manifest.ManifestHeaderProcessor.NameValuePair;
import org.apache.openejb.config.AnnotationDeployer;
import org.apache.openejb.config.AppModule;
import org.apache.openejb.config.EjbModule;
import org.apache.openejb.config.ReadDescriptors;
import org.apache.openejb.jee.EjbJar;
import org.apache.openejb.jee.EnterpriseBean;
import org.apache.openejb.jee.SessionBean;
import org.osgi.framework.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* An {@link EJBLocator} that uses OpenEJB to find EJBs
*
*/
public class OpenEJBLocator implements EJBLocator {
private static final Logger logger = LoggerFactory.getLogger(OpenEJBLocator.class);
public class ClasspathIDirectory implements IDirectory {
private final IDirectory parent;
private final String entry;
public ClasspathIDirectory(IDirectory parent, String name) {
this.parent = parent;
this.entry = (name.endsWith("/")) ? name : name + "/";
}
public IDirectory convert() {
return parent.convert();
}
public IDirectory convertNested() {
return parent.convertNested();
}
public IFile getFile(String arg0) {
return parent.getFile(entry + arg0);
}
public long getLastModified() {
return parent.getLastModified();
}
public String getName() {
return parent.getName() + entry;
}
public IDirectory getParent() {
return parent.getParent();
}
public IDirectory getRoot() {
return parent.getRoot();
}
public long getSize() {
return parent.getSize();
}
public boolean isDirectory() {
return parent.isDirectory();
}
public boolean isFile() {
return parent.isFile();
}
public boolean isRoot() {
return parent.isRoot();
}
public Iterator<IFile> iterator() {
return parent.iterator();
}
public List<IFile> listAllFiles() {
List<IFile> files = new ArrayList<IFile>();
for(IFile f : parent.listAllFiles()) {
if(f.getName().startsWith(entry))
files.add(f);
}
return files;
}
public List<IFile> listFiles() {
List<IFile> files = new ArrayList<IFile>();
for(IFile f : parent.listFiles()) {
if(f.getName().startsWith(entry))
files.add(f);
}
return files;
}
public InputStream open() throws IOException, UnsupportedOperationException {
return parent.open();
}
public ICloseableDirectory toCloseable() {
return parent.toCloseable();
}
public URL toURL() throws MalformedURLException {
return parent.toURL();
}
}
public void findEJBs(BundleManifest manifest, IDirectory bundle,
EJBRegistry registry) throws ModellerException {
logger.debug("Scanning " + manifest.getSymbolicName() + "_" + manifest.getManifestVersion() +
" for EJBs");
String ejbJarLocation = (manifest.getRawAttributes().getValue(
"Web-ContextPath") == null) ? "META-INF/ejb-jar.xml" : "WEB-INF/ejb-jar.xml";
try {
//If we have an ejb-jar.xml then parse it
IFile file = bundle.getFile(ejbJarLocation);
EjbJar ejbJar = (file == null) ? new EjbJar() : ReadDescriptors.readEjbJar(file.toURL());
EjbModule module = new EjbModule(ejbJar);
//We build our own because we can't trust anyone to get the classpath right otherwise!
module.setFinder(new IDirectoryFinder(AnnotationDeployer.class.getClassLoader(),
getClassPathLocations(manifest, bundle)));
//Scan our app for annotated EJBs
AppModule app = new AppModule(module);
new AnnotationDeployer().deploy(app);
//Register our session beans
for(EnterpriseBean eb : ejbJar.getEnterpriseBeans()) {
if(!!!(eb instanceof SessionBean))
continue;
else
registerSessionBean(registry, (SessionBean) eb);
}
} catch (Exception e) {
throw new ModellerException(e);
}
}
/**
* Find the classpath entries for our bundle
*
* @param manifest
* @param bundle
* @return
*/
private List<IDirectory> getClassPathLocations(BundleManifest manifest,
IDirectory bundle) {
List<IDirectory> result = new ArrayList<IDirectory>();
String rawCp = manifest.getRawAttributes().getValue(Constants.BUNDLE_CLASSPATH);
logger.debug("Classpath is " + rawCp);
if(rawCp == null || rawCp.trim() == "")
result.add(bundle);
else {
List<NameValuePair> splitCp = ManifestHeaderProcessor.parseExportString(rawCp);
List<IFile> allFiles = null;
for(NameValuePair nvp : splitCp) {
String name = nvp.getName().trim();
if(".".equals(name)) {
result.add(bundle);
}
else {
IFile f = bundle.getFile(name);
if(f==null) {
//This possibly just means no directory entries in a
//Zip. Check to make sure
if(allFiles == null)
allFiles = bundle.listAllFiles();
for(IFile file : allFiles) {
if(file.getName().startsWith(name)) {
result.add(new ClasspathIDirectory(bundle, name));
break;
}
}
} else {
IDirectory converted = f.convertNested();
if(converted != null)
result.add(converted);
}
}
}
}
return result;
}
/**
* Register a located session bean with the {@link EJBRegistry}
* @param registry
* @param sb
*/
private void registerSessionBean(EJBRegistry registry, SessionBean sb) {
String name = sb.getEjbName();
String type = sb.getSessionType().toString();
logger.debug("Found EJB " + name + " of type " + type);
boolean added = false;
for(String iface : sb.getBusinessLocal()) {
added = true;
registry.addEJBView(name, type, iface, false);
}
for(String iface : sb.getBusinessRemote()) {
added = true;
registry.addEJBView(name, type, iface, true);
}
if(sb.getLocal() != null) {
added = true;
registry.addEJBView(name, type, sb.getLocal(), false);
}
if(sb.getLocalHome() != null) {
added = true;
registry.addEJBView(name, type, sb.getLocalHome(), false);
}
if(sb.getRemote() != null) {
added = true;
registry.addEJBView(name, type, sb.getRemote(), true);
}
if(sb.getHome() != null) {
added = true;
registry.addEJBView(name, type, sb.getHome(), true);
}
//If not added elsewhere then we have a no-interface view
if(!!!added) {
registry.addEJBView(name, type, sb.getEjbClass(), false);
}
}
} | 9,020 |
0 | Create_ds/aries/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling | Create_ds/aries/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBLocationUnavailable.java | /**
* 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.aries.ejb.modelling.impl;
import org.apache.aries.application.modelling.ModellerException;
import org.apache.aries.ejb.modelling.EJBLocator;
import org.apache.aries.ejb.modelling.EJBRegistry;
import org.apache.aries.util.filesystem.IDirectory;
import org.apache.aries.util.manifest.BundleManifest;
/**
* An EJB Locator implementation for when EJB location is unavailable.
* It will cause any modelling that might involve EJBs to fail.
*/
public class EJBLocationUnavailable implements EJBLocator {
public void findEJBs(BundleManifest manifest, IDirectory bundle,
EJBRegistry registry) throws ModellerException {
throw new ModellerException("No OpenEJB runtime present");
}
}
| 9,021 |
0 | Create_ds/aries/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling | Create_ds/aries/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBLocatorFactory.java | /**
* 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.aries.ejb.modelling.impl;
import org.apache.aries.ejb.modelling.EJBLocator;
/**
* A factory for creating our internal EJBLocator without a hard dependency on
* OpenEJB
*/
public class EJBLocatorFactory {
public static EJBLocator getEJBLocator() {
try {
Class.forName("org.apache.openejb.config.AnnotationDeployer");
Class.forName("org.apache.openejb.jee.SessionBean");
Class.forName("org.apache.xbean.finder.ClassFinder");
return new OpenEJBLocator();
} catch (Exception e) {
return new EJBLocationUnavailable();
}
}
}
| 9,022 |
0 | Create_ds/aries/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb | Create_ds/aries/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/RunningApplication.java | /**
* 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.aries.ejb.openejb.extender;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.persistence.EntityManagerFactory;
import org.apache.aries.jpa.container.PersistenceUnitConstants;
import org.apache.aries.jpa.container.context.PersistenceContextProvider;
import org.apache.aries.util.AriesFrameworkUtil;
import org.apache.aries.util.manifest.ManifestHeaderProcessor;
import org.apache.aries.util.manifest.ManifestHeaderProcessor.NameValuePair;
import org.apache.openejb.AppContext;
import org.apache.openejb.BeanContext;
import org.apache.openejb.ContainerType;
import org.apache.openejb.assembler.classic.EnterpriseBeanInfo;
import org.apache.openejb.assembler.classic.PersistenceContextReferenceInfo;
import org.apache.openejb.assembler.classic.PersistenceUnitReferenceInfo;
import org.apache.openejb.assembler.classic.ProxyInterfaceResolver;
import org.apache.openejb.assembler.classic.ReferenceLocationInfo;
import org.apache.openejb.jee.EnterpriseBean;
import org.apache.openejb.persistence.JtaEntityManager;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;
public class RunningApplication implements ServiceTrackerCustomizer {
private static final String NONE = "NONE";
private final AppContext ctx;
private final Bundle bundle;
private final Collection<ServiceRegistration<?>> regs =
new ArrayList<ServiceRegistration<?>>();
private ServiceTracker tracker;
private final ConcurrentMap<String, ConcurrentMap<Context, PersistenceUnitReferenceInfo>>
unitRegistrations = new ConcurrentHashMap<String, ConcurrentMap<Context, PersistenceUnitReferenceInfo>>();
private final ConcurrentMap<String, ConcurrentMap<Context, PersistenceContextReferenceInfo>>
contextRegistrations = new ConcurrentHashMap<String, ConcurrentMap<Context, PersistenceContextReferenceInfo>>();
public RunningApplication(AppContext context, Bundle bundle, List<EnterpriseBeanInfo> enterpriseBeans) {
this.ctx = context;
this.bundle = bundle;
for(EnterpriseBeanInfo bean : enterpriseBeans) {
for(PersistenceUnitReferenceInfo pui : bean.jndiEnc.persistenceUnitRefs) {
ConcurrentMap<Context, PersistenceUnitReferenceInfo> map = unitRegistrations.
get(pui.persistenceUnitName);
if(map == null) {
map = new ConcurrentHashMap<Context, PersistenceUnitReferenceInfo>();
unitRegistrations.put(pui.persistenceUnitName, map);
}
for(BeanContext eb : ctx.getBeanContexts()) {
if(eb.getEjbName().equals(bean.ejbName)){
map.put(eb.getJndiContext(), pui);
continue;
}
}
}
for(PersistenceContextReferenceInfo pci : bean.jndiEnc.persistenceContextRefs) {
ConcurrentMap<Context, PersistenceContextReferenceInfo> map = contextRegistrations.
get(pci.persistenceUnitName);
if(map == null) {
map = new ConcurrentHashMap<Context, PersistenceContextReferenceInfo>();
contextRegistrations.put(pci.persistenceUnitName, map);
}
for(BeanContext eb : ctx.getBeanContexts()) {
if(eb.getEjbName().equals(bean.ejbName)){
map.put(eb.getJndiContext(), pci);
continue;
}
}
}
}
}
public AppContext getCtx() {
return ctx;
}
public void init() {
tracker = new ServiceTracker(bundle.getBundleContext(),
EntityManagerFactory.class.getName(), this);
tracker.open();
registerEJBs();
}
public void destroy() {
tracker.close();
for(ServiceRegistration<?> reg : regs) {
AriesFrameworkUtil.safeUnregisterService(reg);
}
}
private void registerEJBs() {
Collection<String> names = new HashSet<String>();
Dictionary<String, String> d = bundle.getHeaders();
String valueOfExportEJBHeader = d.get("Export-EJB");
if((valueOfExportEJBHeader == null)){
return;
}
if(names.contains(NONE)){
return;
}
List<NameValuePair> contentsOfExportEJBHeader = ManifestHeaderProcessor.parseExportString(valueOfExportEJBHeader);
for(NameValuePair nvp:contentsOfExportEJBHeader){
names.add(nvp.getName());
}
if(valueOfExportEJBHeader.trim().equals("")){
names = new AllCollection<String>();
}
//Register our session beans
for (BeanContext beanContext : ctx.getDeployments()) {
String ejbName = beanContext.getEjbName();
//Skip if not a Singleton or stateless bean
ContainerType type = beanContext.getContainer().getContainerType();
boolean register = type == ContainerType.SINGLETON || type == ContainerType.STATELESS;
//Skip if not allowed name
register &= names.contains(ejbName);
if(!register) {
continue;
}
if (beanContext.isLocalbean()) {
BeanContext.BusinessLocalBeanHome home = beanContext.getBusinessLocalBeanHome();
Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("ejb.name", ejbName);
props.put("ejb.type", getCasedType(type));
regs.add(bundle.getBundleContext().registerService(beanContext.getBeanClass().getName(),
new EJBServiceFactory(home), props));
}
for (Class<?> interfce : beanContext.getBusinessLocalInterfaces()) {
BeanContext.BusinessLocalHome home = beanContext.getBusinessLocalHome(interfce);
Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("ejb.name", ejbName);
props.put("ejb.type", getCasedType(type));
regs.add(bundle.getBundleContext().registerService(interfce.getName(),
new EJBServiceFactory(home), props));
}
for (Class<?> interfce : beanContext.getBusinessRemoteInterfaces()) {
List<Class> interfaces = ProxyInterfaceResolver.getInterfaces(beanContext.getBeanClass(),
interfce, beanContext.getBusinessRemoteInterfaces());
BeanContext.BusinessRemoteHome home = beanContext.getBusinessRemoteHome(interfaces, interfce);
Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("sevice.exported.interfaces", interfce.getName());
props.put("ejb.name", ejbName);
props.put("ejb.type", getCasedType(type));
regs.add(bundle.getBundleContext().registerService(interfce.getName(),
new EJBServiceFactory(home), props));
}
}
}
private String getCasedType(ContainerType type) {
String s = type.toString().substring(0,1).toUpperCase();
s += type.toString().substring(1).toLowerCase();
return s;
}
public Object addingService(ServiceReference reference) {
if(isTrue(reference, PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT) &&
!!!isTrue(reference, PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE)) {
Map<Context, PersistenceUnitReferenceInfo> pUnitRefs = unitRegistrations.
get(reference.getProperty(PersistenceUnitConstants.OSGI_UNIT_NAME));
Map<Context, PersistenceContextReferenceInfo> pCtxRefs = contextRegistrations.
get(reference.getProperty(PersistenceUnitConstants.OSGI_UNIT_NAME));
if(pUnitRefs == null) {
pUnitRefs = new HashMap<Context, PersistenceUnitReferenceInfo>();
}
if(pCtxRefs == null) {
pCtxRefs = new HashMap<Context, PersistenceContextReferenceInfo>();
}
if(pUnitRefs.size() > 0 || pCtxRefs.size() > 0) {
EntityManagerFactory emf = (EntityManagerFactory)bundle.getBundleContext().getService(reference);
for(Entry<Context, PersistenceUnitReferenceInfo> e : pUnitRefs.entrySet()) {
try {
e.getKey().bind(e.getValue().referenceName, emf);
} catch (NamingException ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
}
}
for(Entry<Context, PersistenceContextReferenceInfo> e : pCtxRefs.entrySet()) {
PersistenceContextReferenceInfo pci = e.getValue();
try {
e.getKey().bind(pci.referenceName, new JtaEntityManager((String)reference.getProperty(
PersistenceUnitConstants.OSGI_UNIT_NAME), AriesPersistenceContextIntegration.get(),
emf, pci.properties, pci.extended));
} catch (NamingException ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
}
}
return emf;
}
}
return null;
}
private boolean isTrue(ServiceReference reference,
String key) {
return Boolean.parseBoolean(String.valueOf(reference.getProperty(key)));
}
public void modifiedService(ServiceReference reference, Object service) {
//No op
}
public void removedService(ServiceReference reference, Object service) {
Map<Context, PersistenceUnitReferenceInfo> pUnitRefs = unitRegistrations.
get(reference.getProperty(PersistenceUnitConstants.OSGI_UNIT_NAME));
Map<Context, PersistenceContextReferenceInfo> pCtxRefs = contextRegistrations.
get(reference.getProperty(PersistenceUnitConstants.OSGI_UNIT_NAME));
if(pUnitRefs == null) {
pUnitRefs = new HashMap<Context, PersistenceUnitReferenceInfo>();
}
if(pCtxRefs == null) {
pCtxRefs = new HashMap<Context, PersistenceContextReferenceInfo>();
}
if(pUnitRefs.size() > 0 || pCtxRefs.size() > 0) {
for(Entry<Context, PersistenceUnitReferenceInfo> e : pUnitRefs.entrySet()) {
try {
e.getKey().unbind(e.getValue().referenceName);
} catch (NamingException ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
}
}
for(Entry<Context, PersistenceContextReferenceInfo> e : pCtxRefs.entrySet()) {
PersistenceContextReferenceInfo pci = e.getValue();
try {
e.getKey().unbind(pci.referenceName);
} catch (NamingException ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
}
}
}
}
}
| 9,023 |
0 | Create_ds/aries/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb | Create_ds/aries/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/OSGiFinder.java | /**
* 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.aries.ejb.openejb.extender;
import java.io.IOException;
import java.net.URL;
import org.apache.xbean.finder.AbstractFinder;
import org.osgi.framework.Bundle;
import org.osgi.framework.wiring.BundleWiring;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class OSGiFinder extends AbstractFinder {
private final Bundle b;
private static final Logger logger = LoggerFactory.getLogger(OSGiFinder.class);
public OSGiFinder(Bundle bundle) {
b = bundle;
for(String resource : bundle.adapt(BundleWiring.class).
listResources("/", "*.class", BundleWiring.LISTRESOURCES_RECURSE)) {
try {
readClassDef(getResource(resource).openStream());
} catch (IOException e) {
logger.warn("Error processing class file " + resource);
}
}
}
@Override
protected URL getResource(String name) {
return b.getResource(name);
}
@Override
protected Class<?> loadClass(String className) throws ClassNotFoundException {
return b.loadClass(className);
}
}
| 9,024 |
0 | Create_ds/aries/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb | Create_ds/aries/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/AllCollection.java | /**
* 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.aries.ejb.openejb.extender;
import java.util.Collection;
import java.util.Iterator;
public class AllCollection<T> implements Collection<T> {
public boolean add(T object) {
throw new UnsupportedOperationException();
}
public boolean addAll(Collection<? extends T> collection) {
throw new UnsupportedOperationException();
}
public void clear() {
throw new UnsupportedOperationException();
}
public boolean contains(Object object) {
return true;
}
public boolean containsAll(Collection<?> collection) {
return true;
}
public boolean isEmpty() {
return false;
}
public Iterator<T> iterator() {
throw new UnsupportedOperationException();
}
public boolean remove(Object object) {
throw new UnsupportedOperationException();
}
public boolean removeAll(Collection<?> collection) {
throw new UnsupportedOperationException();
}
public boolean retainAll(Collection<?> collection) {
throw new UnsupportedOperationException();
}
public int size() {
throw new UnsupportedOperationException();
}
public Object[] toArray() {
throw new UnsupportedOperationException();
}
public <T> T[] toArray(T[] array) {
throw new UnsupportedOperationException();
}
}
| 9,025 |
0 | Create_ds/aries/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb | Create_ds/aries/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/AriesPersistenceContextIntegration.java | /**
* 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.aries.ejb.openejb.extender;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import org.apache.aries.jpa.container.context.JTAPersistenceContextManager;
import org.apache.aries.util.tracker.SingleServiceTracker;
import org.apache.aries.util.tracker.SingleServiceTracker.SingleServiceListener;
import org.apache.openejb.persistence.EntityManagerTxKey;
import org.apache.openejb.persistence.JtaEntityManagerRegistry;
import org.osgi.framework.BundleContext;
public class AriesPersistenceContextIntegration extends
JtaEntityManagerRegistry {
private static final AtomicReference<AriesPersistenceContextIntegration> INSTANCE =
new AtomicReference<AriesPersistenceContextIntegration>();
private final SingleServiceTracker<JTAPersistenceContextManager> ariesJTARegistry;
private AriesPersistenceContextIntegration(BundleContext ctx) {
super(OSGiTransactionManager.get());
ariesJTARegistry = new SingleServiceTracker<JTAPersistenceContextManager>
(ctx, JTAPersistenceContextManager.class, new DummySingleServiceListener());
ariesJTARegistry.open();
}
public static void init(BundleContext ctx) {
AriesPersistenceContextIntegration apci = new AriesPersistenceContextIntegration(ctx);
if(!!!INSTANCE.compareAndSet(null, apci))
apci.destroy();
}
public static AriesPersistenceContextIntegration get() {
return INSTANCE.get();
}
public void destroy() {
INSTANCE.set(null);
ariesJTARegistry.close();
}
@Override
public EntityManager getEntityManager(EntityManagerFactory emf, Map props,
boolean extended, String unitName) throws IllegalStateException {
if(!!!isTransactionActive())
return super.getEntityManager(emf, props, extended, unitName);
JTAPersistenceContextManager mgr = ariesJTARegistry.getService();
if(mgr == null)
throw new IllegalStateException("No JTAPersistenceContextManager service available");
//Check if we, or OpenEJB, already have a context
EntityManager ariesEM = mgr.getExistingPersistenceContext(emf);
EntityManager openEjbEM = (EntityManager) OSGiTransactionManager.get().
getResource(new EntityManagerTxKey(emf));
if(ariesEM == null) {
if(openEjbEM == null) {
//If both are null then it's easier to let OpenEJB win and push the PC into Aries
openEjbEM = super.getEntityManager(emf, props, extended, unitName);
}
mgr.manageExistingPersistenceContext(emf, openEjbEM);
ariesEM = openEjbEM;
} else {
//We have an Aries EM, if OpenEJB doesn't then sort it out, if it does they should be the same
if(openEjbEM == null){
if(extended) {
throw new IllegalStateException("We already have an active TX scope PersistenceContext, so we can't" +
"create an extended one");
} else {
OSGiTransactionManager.get().putResource(new EntityManagerTxKey(emf), ariesEM);
openEjbEM = ariesEM;
}
} else {
//If both non null and not equal then something bad has happened
if(openEjbEM != ariesEM) {
throw new IllegalStateException("OpenEJB has been cheating. They have a different EntityManager to Aries");
}
}
}
//We could return either ariesEM or openEjbEM at this point
return ariesEM;
}
private static final class DummySingleServiceListener implements SingleServiceListener {
public void serviceFound() {}
public void serviceLost() {}
public void serviceReplaced() {}
}
}
| 9,026 |
0 | Create_ds/aries/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb | Create_ds/aries/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/OSGiTransactionManager.java | /**
* 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.aries.ejb.openejb.extender;
import java.util.concurrent.atomic.AtomicReference;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
import javax.transaction.InvalidTransactionException;
import javax.transaction.NotSupportedException;
import javax.transaction.RollbackException;
import javax.transaction.Synchronization;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import javax.transaction.TransactionSynchronizationRegistry;
import org.apache.aries.util.tracker.SingleServiceTracker;
import org.apache.aries.util.tracker.SingleServiceTracker.SingleServiceListener;
import org.osgi.framework.BundleContext;
public class OSGiTransactionManager implements TransactionManager,
TransactionSynchronizationRegistry, SingleServiceListener {
private static class NoTransactionManagerException extends SystemException {
public NoTransactionManagerException() {
super("No Transaction Manager is available");
}
}
private static class NoTransactionSynchronizationRegistryException extends RuntimeException {
public NoTransactionSynchronizationRegistryException() {
super("No Transaction Synchronization Registry is available");
}
}
private final SingleServiceTracker<TransactionManager> tmTracker;
private final SingleServiceTracker<TransactionSynchronizationRegistry> tsrTracker;
private final AtomicReference<TransactionManager> tm =
new AtomicReference<TransactionManager>();
private final AtomicReference<TransactionSynchronizationRegistry> tsr =
new AtomicReference<TransactionSynchronizationRegistry>();
private static final AtomicReference<OSGiTransactionManager> INSTANCE =
new AtomicReference<OSGiTransactionManager>();
private OSGiTransactionManager(BundleContext ctx) {
tmTracker = new SingleServiceTracker<TransactionManager>(ctx, TransactionManager.class, this);
tsrTracker = new SingleServiceTracker<TransactionSynchronizationRegistry>(ctx,
TransactionSynchronizationRegistry.class, this);
tmTracker.open();
tsrTracker.open();
}
private final TransactionManager getTM() throws SystemException {
TransactionManager tManager = tm.get();
if(tManager == null) {
throw new NoTransactionManagerException();
}
return tManager;
}
private final TransactionSynchronizationRegistry getTSR() {
TransactionSynchronizationRegistry tSReg = tsr.get();
if(tSReg == null) {
throw new NoTransactionSynchronizationRegistryException();
}
return tSReg;
}
public static OSGiTransactionManager get() {
return INSTANCE.get();
}
public static void init(BundleContext ctx) {
OSGiTransactionManager oTM = new OSGiTransactionManager(ctx);
if(!!!INSTANCE.compareAndSet(null, oTM))
oTM.destroy();
}
public void destroy() {
INSTANCE.set(null);
tmTracker.close();
tsrTracker.close();
}
public void serviceFound() {
update();
}
public void serviceLost() {
update();
}
public void serviceReplaced() {
update();
}
private void update() {
tm.set(tmTracker.getService());
tsr.set(tsrTracker.getService());
}
public void begin() throws NotSupportedException, SystemException {
getTM().begin();
}
public void commit() throws HeuristicMixedException,
HeuristicRollbackException, IllegalStateException, RollbackException,
SecurityException, SystemException {
getTM().commit();
}
public int getStatus() throws SystemException {
return getTM().getStatus();
}
public Transaction getTransaction() throws SystemException {
return getTM().getTransaction();
}
public void resume(Transaction arg0) throws IllegalStateException,
InvalidTransactionException, SystemException {
getTM().resume(arg0);
}
public void rollback() throws IllegalStateException, SecurityException,
SystemException {
getTM().rollback();
}
public void setRollbackOnly() throws IllegalStateException {
getTSR().setRollbackOnly();
}
public void setTransactionTimeout(int arg0) throws SystemException {
getTM().setTransactionTimeout(arg0);
}
public Transaction suspend() throws SystemException {
return getTM().suspend();
}
public Object getResource(Object arg0) {
return getTSR().getResource(arg0);
}
public boolean getRollbackOnly() {
return getTSR().getRollbackOnly();
}
public Object getTransactionKey() {
return getTSR().getTransactionKey();
}
public int getTransactionStatus() {
return getTSR().getTransactionStatus();
}
public void putResource(Object arg0, Object arg1) {
getTSR().putResource(arg0, arg1);
}
public void registerInterposedSynchronization(Synchronization arg0) {
getTSR().registerInterposedSynchronization(arg0);
}
}
| 9,027 |
0 | Create_ds/aries/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb | Create_ds/aries/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/EJBExtender.java | /**
* 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.aries.ejb.openejb.extender;
import java.io.IOException;
import java.lang.reflect.Field;
import java.net.URL;
import java.util.Collections;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import javax.naming.NamingException;
import org.apache.aries.util.AriesFrameworkUtil;
import org.apache.aries.util.tracker.RecursiveBundleTracker;
import org.apache.openejb.OpenEJBException;
import org.apache.openejb.assembler.classic.Assembler;
import org.apache.openejb.assembler.classic.EjbJarInfo;
import org.apache.openejb.assembler.classic.EnterpriseBeanInfo;
import org.apache.openejb.assembler.classic.PersistenceContextReferenceInfo;
import org.apache.openejb.assembler.classic.PersistenceUnitReferenceInfo;
import org.apache.openejb.assembler.classic.ProxyFactoryInfo;
import org.apache.openejb.assembler.classic.ReferenceLocationInfo;
import org.apache.openejb.assembler.classic.SecurityServiceInfo;
import org.apache.openejb.assembler.classic.TransactionServiceInfo;
import org.apache.openejb.assembler.dynamic.PassthroughFactory;
import org.apache.openejb.config.ConfigurationFactory;
import org.apache.openejb.config.EjbModule;
import org.apache.openejb.config.ValidationContext;
import org.apache.openejb.loader.SystemInstance;
import org.apache.openejb.persistence.JtaEntityManagerRegistry;
import org.apache.openejb.ri.sp.PseudoSecurityService;
import org.apache.openejb.util.OpenEjbVersion;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.util.tracker.BundleTrackerCustomizer;
public class EJBExtender implements BundleActivator, BundleTrackerCustomizer {
private static final int STARTABLE = Bundle.STARTING | Bundle.ACTIVE;
private static final Object PROCESSING_OBJECT = new Object();
private static final Object REMOVING_OBJECT = new Object();
private RecursiveBundleTracker tracker;
private final ConcurrentMap<Bundle, RunningApplication> runningApps =
new ConcurrentHashMap<Bundle, RunningApplication>();
private final ConcurrentMap<Bundle, Object> processingMap =
new ConcurrentHashMap<Bundle, Object>();
public void start(BundleContext context) throws Exception {
//Internal setup
OSGiTransactionManager.init(context);
AriesProxyService.init(context);
try {
AriesPersistenceContextIntegration.init(context);
} catch (NoClassDefFoundError ncdfe) {
//TODO log that no JPA Context integration is available
}
//Setup OpenEJB with our own extensions
setupOpenEJB();
tracker = new RecursiveBundleTracker(context, Bundle.INSTALLED | Bundle.RESOLVED |
Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING, this);
tracker.open();
}
private void setupOpenEJB() throws OpenEJBException {
//Avoid a ClassLoader problem
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(OpenEjbVersion.class.getClassLoader());
OpenEjbVersion.get();
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
Assembler a = new Assembler();
TransactionServiceInfo tsi = new TransactionServiceInfo();
tsi.service = "TransactionManager";
tsi.id = "OSGi Transaction Manager";
PassthroughFactory.add(tsi, OSGiTransactionManager.get());
//Avoid another ClassLoader problem
try {
Thread.currentThread().setContextClassLoader(PassthroughFactory.class.getClassLoader());
a.createTransactionManager(tsi);
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
try {
//Overwrite existing, default JPA integration with an Aries JPA integrated one
Assembler.getContext().put(JtaEntityManagerRegistry.class.getName(),
AriesPersistenceContextIntegration.get());
SystemInstance.get().setComponent(JtaEntityManagerRegistry.class,
AriesPersistenceContextIntegration.get());
} catch (NoClassDefFoundError ncdfe) {
//TODO log that no JPA Context integration is available
}
SecurityServiceInfo ssi = new SecurityServiceInfo();
ssi.service = "SecurityService";
ssi.id = "Pseudo Security Service";
PassthroughFactory.add(ssi, new PseudoSecurityService());
//Avoid another ClassLoader problem
try {
Thread.currentThread().setContextClassLoader(PassthroughFactory.class.getClassLoader());
a.createSecurityService(ssi);
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
ProxyFactoryInfo proxyFactoryInfo = new ProxyFactoryInfo();
proxyFactoryInfo.id = "Aries ProxyFactory";
proxyFactoryInfo.service = "ProxyFactory";
proxyFactoryInfo.properties = new Properties();
PassthroughFactory.add(proxyFactoryInfo, AriesProxyService.get());
try {
Thread.currentThread().setContextClassLoader(PassthroughFactory.class.getClassLoader());
a.createProxyFactory(proxyFactoryInfo);
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
}
public void stop(BundleContext context) throws Exception {
tracker.close();
AriesProxyService.get().destroy();
OSGiTransactionManager.get().destroy();
try {
AriesPersistenceContextIntegration.get().destroy();
} catch (NoClassDefFoundError ncdfe) {
//TODO log that no JPA Context integration is available
}
}
public Object addingBundle(Bundle bundle, BundleEvent event) {
if(mightContainEJBs(bundle)) {
if((bundle.getState() & STARTABLE) != 0) {
startEJBs(bundle);
}
return bundle;
}
return null;
}
private boolean mightContainEJBs(Bundle bundle) {
Dictionary<String, String> headers = bundle.getHeaders();
return (headers.get("Export-EJB") != null) || (headers.get("Web-ContextPath") != null);
}
public void modifiedBundle(Bundle bundle, BundleEvent event, Object object) {
if((bundle.getState() & STARTABLE) != 0) {
startEJBs(bundle);
} else if (bundle.getState() == Bundle.STOPPING) {
stopEJBs(bundle);
}
}
private void startEJBs(final Bundle bundle) {
try {
//If there is another thread adding or removing then stop here
Object o = processingMap.put(bundle, PROCESSING_OBJECT);
if(o == REMOVING_OBJECT || o == PROCESSING_OBJECT) {
return;
}
//If already running then avoid
if(runningApps.get(bundle) != null)
return;
//Broken validation for persistence :(
EjbModule ejbModule = new EjbModule(AriesFrameworkUtil.getClassLoaderForced(bundle), null, null, null);
try {
Field f = EjbModule.class.getDeclaredField("validation");
f.setAccessible(true);
f.set(ejbModule, new ValidationProofValidationContext(ejbModule));
} catch (Exception e) {
// Hmmm
}
addAltDDs(ejbModule, bundle);
//We build our own because we can't trust anyone to get the classpath right otherwise!
ejbModule.setFinder(new OSGiFinder(bundle));
ConfigurationFactory configurationFactory = new ConfigurationFactory();
EjbJarInfo ejbInfo = null;
//Avoid yet another ClassLoading problem
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(new ClassLoader(OpenEjbVersion.class.getClassLoader()) {
protected Class<?> findClass(String name) throws ClassNotFoundException {
for(Bundle b : bundle.getBundleContext().getBundles()) {
if(b.getSymbolicName().contains("jaxb-impl"))
return b.loadClass(name);
}
throw new ClassNotFoundException(name);
}
});
ejbInfo = configurationFactory.configureApplication(ejbModule);
//Another oddity here
ejbInfo.validationInfo = null;
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
processJPAMappings(ejbInfo);
Assembler assembler = (Assembler) SystemInstance.get().getComponent(Assembler.class);
RunningApplication app = null;
try {
SystemInstance.get().setProperty("openejb.geronimo", "true");
cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(OpenEjbVersion.class.getClassLoader());
app = new RunningApplication(assembler.createApplication(ejbInfo,
new AppClassLoader(ejbModule.getClassLoader())), bundle, ejbInfo.enterpriseBeans);
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
} finally {
SystemInstance.get().getProperties().remove("openejb.geronimo");
}
runningApps.put(bundle, app);
app.init();
} catch (OpenEJBException oee) {
// TODO Auto-generated catch block
oee.printStackTrace();
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if(processingMap.remove(bundle) == REMOVING_OBJECT) {
stopEJBs(bundle);
}
}
}
private void processJPAMappings(EjbJarInfo ejbInfo) {
for(EnterpriseBeanInfo ebi : ejbInfo.enterpriseBeans){
for(PersistenceUnitReferenceInfo pui : ebi.jndiEnc.persistenceUnitRefs) {
pui.location = new ReferenceLocationInfo();
pui.location.jndiName = "aries/integration/unit/" + pui.persistenceUnitName;
}
for(PersistenceContextReferenceInfo pci : ebi.jndiEnc.persistenceContextRefs) {
pci.location = new ReferenceLocationInfo();
pci.location.jndiName = "aries/integration/context/" + pci.persistenceUnitName;
}
}
}
private void addAltDDs(EjbModule ejbModule, Bundle bundle) {
Map<String, Object> altDDs = ejbModule.getAltDDs();
String folder = (bundle.getHeaders().get("Web-ContextPath") == null) ?
"META-INF" : "WEB-INF";
Enumeration<URL> e = bundle.findEntries(folder, "*.xml", false);
if(e == null)
return;
for(URL u : Collections.list(e)) {
String urlString = u.toExternalForm();
urlString = urlString.substring(urlString.lastIndexOf('/') + 1);
altDDs.put(urlString, u);
}
//Persistence descriptors are handled by Aries JPA, but OpenEJB fails validation
//if we hide them. As a result we switch it off.
//altDDs.remove("persistence.xml");
}
private void stopEJBs(Bundle bundle) {
if(processingMap.put(bundle, REMOVING_OBJECT) == PROCESSING_OBJECT)
return;
else {
try {
RunningApplication app = runningApps.remove(bundle);
if(app != null) {
app.destroy();
Assembler assembler = (Assembler) SystemInstance.get().getComponent(Assembler.class);
assembler.destroyApplication(app.getCtx());
}
} catch (OpenEJBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if(processingMap.remove(bundle) == PROCESSING_OBJECT)
startEJBs(bundle);
}
}
}
public void removedBundle(Bundle bundle, BundleEvent event, Object object) {
if (bundle.getState() == Bundle.STOPPING) {
stopEJBs(bundle);
}
}
private static final class ValidationProofValidationContext extends ValidationContext {
private ValidationProofValidationContext(EjbModule mod) {
super(mod);
}
@Override
public boolean hasErrors() {
return false;
}
@Override
public boolean hasFailures() {
return false;
}
@Override
public boolean hasWarnings() {
return false;
}
}
private static final class AppClassLoader extends ClassLoader {
private AppClassLoader(ClassLoader parentLoader) {
super(parentLoader);
}
@Override
protected Class<?> findClass(String className)
throws ClassNotFoundException {
return Class.forName(className, false, OpenEjbVersion.class.getClassLoader());
}
}
}
| 9,028 |
0 | Create_ds/aries/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb | Create_ds/aries/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/EJBServiceFactory.java | /**
* 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.aries.ejb.openejb.extender;
import org.apache.openejb.BeanContext.BusinessLocalBeanHome;
import org.apache.openejb.BeanContext.BusinessLocalHome;
import org.apache.openejb.BeanContext.BusinessRemoteHome;
import org.apache.openejb.core.ivm.BaseEjbProxyHandler;
import org.apache.openejb.util.proxy.InvocationHandler;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceRegistration;
public class EJBServiceFactory implements ServiceFactory<Object> {
private static enum Type {LOCAL, LOCAL_NO_IFACE, REMOTE;}
private final BusinessLocalBeanHome localBeanHome;
private final BusinessLocalHome localHome;
private final BusinessRemoteHome remoteHome;
private final Type type;
public EJBServiceFactory(BusinessLocalBeanHome home) {
this.localBeanHome = home;
type = Type.LOCAL_NO_IFACE;
this.remoteHome = null;
this.localHome = null;
}
public EJBServiceFactory(BusinessLocalHome home) {
this.localHome = home;
type = Type.LOCAL;
this.remoteHome = null;
this.localBeanHome = null;
}
public EJBServiceFactory(BusinessRemoteHome home) {
this.remoteHome = home;
type = Type.REMOTE;
this.localHome = null;
this.localBeanHome = null;
}
public Object getService(Bundle bundle,
ServiceRegistration<Object> registration) {
switch(type) {
case LOCAL :
return localHome.create();
case LOCAL_NO_IFACE :
return localBeanHome.create();
case REMOTE : {
InvocationHandler ih = AriesProxyService.get().getInvocationHandler(remoteHome);
if(ih instanceof BaseEjbProxyHandler) {
((BaseEjbProxyHandler)ih).setIntraVmCopyMode(false);
}
return remoteHome.create();
}
default :
throw new IllegalArgumentException("Unknown EJB type " + type);
}
}
public void ungetService(Bundle bundle,
ServiceRegistration<Object> registration, Object service) {
}
}
| 9,029 |
0 | Create_ds/aries/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb | Create_ds/aries/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/AriesProxyService.java | /**
* 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.aries.ejb.openejb.extender;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.WeakHashMap;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.aries.proxy.InvocationListener;
import org.apache.aries.proxy.ProxyManager;
import org.apache.aries.proxy.UnableToProxyException;
import org.apache.aries.util.tracker.SingleServiceTracker;
import org.apache.aries.util.tracker.SingleServiceTracker.SingleServiceListener;
import org.apache.openejb.OpenEJBException;
import org.apache.openejb.util.proxy.InvocationHandler;
import org.apache.openejb.util.proxy.ProxyFactory;
import org.osgi.framework.BundleContext;
public class AriesProxyService implements ProxyFactory, SingleServiceListener {
private static class NoProxySupportException extends RuntimeException {
public NoProxySupportException() {
super("No Proxy support is available");
}
}
private static final class InvocationHandlerProxy implements Callable<Object>, InvocationListener {
private final InvocationHandler handler;
private final Map<Thread, Class<?>> invocations = new ConcurrentHashMap<Thread, Class<?>>();
private final ConcurrentMap<Class<?>, Object> proxys = new ConcurrentHashMap<Class<?>, Object>();
public InvocationHandlerProxy(InvocationHandler handler) {
this.handler = handler;
}
public InvocationHandler getHandler() {
return handler;
}
public void postInvoke(Object arg0, Object arg1, Method arg2, Object arg3)
throws Throwable {
// No op
}
public void postInvokeExceptionalReturn(Object arg0, Object arg1,
Method arg2, Throwable arg3) throws Throwable {
//No op
}
public Object preInvoke(Object arg0, Method arg1, Object[] arg2)
throws Throwable {
invocations.put(Thread.currentThread(), arg1.getDeclaringClass());
return null;
}
public Object call() throws Exception {
Class<?> c = invocations.remove(Thread.currentThread());
if(c == null)
throw new IllegalStateException("Unable to establish any context");
else if (c.equals(Object.class)) {
//This is a toString or similar, just use an interface we know
//we can see and that doesn't have any methods on it :)
c = Serializable.class;
}
Object proxy = proxys.get(c);
if(proxy == null) {
Object tmp = Proxy.newProxyInstance(c.getClassLoader(), new Class[] {c}, handler);
proxy = proxys.putIfAbsent(c, tmp);
if(proxy == null)
proxy = tmp;
}
return proxy;
}
}
private static class InnerProxyDelegator implements Callable<Object> {
private final Object delegate;
public InnerProxyDelegator(Object delegate) {
this.delegate = delegate;
}
public Object call() {
return delegate;
}
}
private final Map<Class<?>, Object> proxies = Collections.synchronizedMap(
new WeakHashMap<Class<?>, Object>());
private final SingleServiceTracker<ProxyManager> proxyTracker;
private AriesProxyService(BundleContext ctx) {
proxyTracker = new SingleServiceTracker<ProxyManager>(ctx, ProxyManager.class, this);
proxyTracker.open();
}
private final AtomicReference<ProxyManager> manager =
new AtomicReference<ProxyManager>();
private static final AtomicReference<AriesProxyService> INSTANCE =
new AtomicReference<AriesProxyService>();
private final ProxyManager getManager() {
ProxyManager pManager = manager.get();
if(pManager == null) {
throw new NoProxySupportException();
}
return pManager;
}
public static AriesProxyService get() {
return INSTANCE.get();
}
public static void init(BundleContext ctx) {
AriesProxyService oTM = new AriesProxyService(ctx);
if(!!!INSTANCE.compareAndSet(null, oTM))
oTM.destroy();
}
public void destroy() {
INSTANCE.set(null);
proxyTracker.close();
}
public void serviceFound() {
update();
}
public void serviceLost() {
update();
}
public void serviceReplaced() {
update();
}
private void update() {
manager.set(proxyTracker.getService());
}
public InvocationHandler getInvocationHandler(Object arg0)
throws IllegalArgumentException {
Callable<Object> unwrapped = getManager().unwrap(arg0);
if(unwrapped instanceof InnerProxyDelegator) {
unwrapped = getManager().unwrap(((InnerProxyDelegator)unwrapped).call());
}
if(unwrapped instanceof InvocationHandlerProxy) {
return ((InvocationHandlerProxy) unwrapped).getHandler();
}
return null;
}
public Class getProxyClass(Class iface) throws IllegalArgumentException {
if(iface == null || !!!iface.isInterface())
throw new IllegalArgumentException("Not an interface " + iface);
return newProxyInstance(iface, null).getClass();
}
public Class getProxyClass(Class[] ifaces) throws IllegalArgumentException {
if(ifaces == null || ifaces.length == 0)
throw new IllegalArgumentException("No interfaces.");
for(Class iface : ifaces) {
if (!!!iface.isInterface())
throw new IllegalArgumentException("Not an interface " + iface + " in " + Arrays.toString(ifaces));
}
return newProxyInstance(ifaces, null).getClass();
}
public void init(Properties arg0) throws OpenEJBException {
//No op
}
public boolean isProxyClass(Class arg0) {
return proxies.containsKey(arg0);
}
public Object newProxyInstance(Class iface, InvocationHandler arg1)
throws IllegalArgumentException {
return newProxyInstance(new Class[] {iface}, arg1);
}
public Object newProxyInstance(Class[] ifaces, InvocationHandler arg1)
throws IllegalArgumentException {
InvocationHandlerProxy ihProxy = new InvocationHandlerProxy(arg1);
List<Class<?>> classes = new ArrayList<Class<?>>();
for(Class<?> iface : ifaces)
classes.add(iface);
try {
Object inner = getManager().createDelegatingProxy(null, classes, ihProxy, null);
Object proxy = getManager().createDelegatingInterceptingProxy(null, classes,
new InnerProxyDelegator(inner), null, ihProxy);
proxies.put(proxy.getClass(), null);
return proxy;
} catch (UnableToProxyException e) {
throw new IllegalArgumentException(e);
}
}
}
| 9,030 |
0 | Create_ds/aries/ejb/ejb-modeller-itest/src/test/java/org/apache/aries/ejb/container | Create_ds/aries/ejb/ejb-modeller-itest/src/test/java/org/apache/aries/ejb/container/itest/EJBModellingTest.java | /* 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.aries.ejb.container.itest;
import static org.ops4j.pax.exam.CoreOptions.composite;
import static org.ops4j.pax.exam.CoreOptions.frameworkProperty;
import static org.ops4j.pax.exam.CoreOptions.junitBundles;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
import static org.ops4j.pax.exam.CoreOptions.vmOption;
import static org.ops4j.pax.exam.CoreOptions.when;
import org.apache.aries.application.modelling.ModelledResourceManager;
import org.apache.aries.application.modelling.ModellingManager;
import org.apache.aries.application.modelling.ServiceModeller;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerClass;
import org.osgi.framework.BundleException;
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerClass.class)
public class EJBModellingTest extends AbstractEJBModellerTest {
@Before
public void setup() throws BundleException {
resolveBundles();
mrm = context().getService(ModelledResourceManager.class);
mm = context().getService(ModellingManager.class);
context().getService(ServiceModeller.class);
}
protected Option baseOptions() {
String localRepo = System.getProperty("maven.repo.local");
if (localRepo == null) {
localRepo = System.getProperty("org.ops4j.pax.url.mvn.localRepository");
}
return composite(
junitBundles(),
mavenBundle("org.ops4j.pax.logging", "pax-logging-api", "1.7.2"),
mavenBundle("org.ops4j.pax.logging", "pax-logging-service", "1.7.2"),
mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
// this is how you set the default log level when using pax
// logging (logProfile)
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
when(localRepo != null).useOptions(vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo))
);
}
@Configuration
public Option[] configuration() {
return CoreOptions.options(
baseOptions(),
frameworkProperty("org.osgi.framework.system.packages.extra").value("sun.misc,javax.xml.namespace;version=1.1"),
frameworkProperty("org.osgi.framework.system.packages")
.value("javax.accessibility,javax.activation,javax.activity,javax.annotation,javax.annotation.processing,javax.crypto,javax.crypto.interfaces,javax.crypto.spec,javax.imageio,javax.imageio.event,javax.imageio.metadata,javax.imageio.plugins.bmp,javax.imageio.plugins.jpeg,javax.imageio.spi,javax.imageio.stream,javax.jws,javax.jws.soap,javax.lang.model,javax.lang.model.element,javax.lang.model.type,javax.lang.model.util,javax.management,javax.management.loading,javax.management.modelmbean,javax.management.monitor,javax.management.openmbean,javax.management.relation,javax.management.remote,javax.management.remote.rmi,javax.management.timer,javax.naming,javax.naming.directory,javax.naming.event,javax.naming.ldap,javax.naming.spi,javax.net,javax.net.ssl,javax.print,javax.print.attribute,javax.print.attribute.standard,javax.print.event,javax.rmi,javax.rmi.CORBA,javax.rmi.ssl,javax.script,javax.security.auth,javax.security.auth.callback,javax.security.auth.kerberos,javax.security.auth.login,javax.security.auth.spi,javax.security.auth.x500,javax.security.cert,javax.security.sasl,javax.sound.midi,javax.sound.midi.spi,javax.sound.sampled,javax.sound.sampled.spi,javax.sql,javax.sql.rowset,javax.sql.rowset.serial,javax.sql.rowset.spi,javax.swing,javax.swing.border,javax.swing.colorchooser,javax.swing.event,javax.swing.filechooser,javax.swing.plaf,javax.swing.plaf.basic,javax.swing.plaf.metal,javax.swing.plaf.multi,javax.swing.plaf.synth,javax.swing.table,javax.swing.text,javax.swing.text.html,javax.swing.text.html.parser,javax.swing.text.rtf,javax.swing.tree,javax.swing.undo,javax.tools,javax.xml,javax.xml.bind,javax.xml.bind.annotation,javax.xml.bind.annotation.adapters,javax.xml.bind.attachment,javax.xml.bind.helpers,javax.xml.bind.util,javax.xml.crypto,javax.xml.crypto.dom,javax.xml.crypto.dsig,javax.xml.crypto.dsig.dom,javax.xml.crypto.dsig.keyinfo,javax.xml.crypto.dsig.spec,javax.xml.datatype,javax.xml.namespace,javax.xml.parsers,javax.xml.soap,javax.xml.stream,javax.xml.stream.events,javax.xml.stream.util,javax.xml.transform,javax.xml.transform.dom,javax.xml.transform.sax,javax.xml.transform.stax,javax.xml.transform.stream,javax.xml.validation,javax.xml.ws,javax.xml.ws.handler,javax.xml.ws.handler.soap,javax.xml.ws.http,javax.xml.ws.soap,javax.xml.ws.spi,javax.xml.xpath,org.ietf.jgss,org.omg.CORBA,org.omg.CORBA.DynAnyPackage,org.omg.CORBA.ORBPackage,org.omg.CORBA.TypeCodePackage,org.omg.CORBA.portable,org.omg.CORBA_2_3,org.omg.CORBA_2_3.portable,org.omg.CosNaming,org.omg.CosNaming.NamingContextExtPackage,org.omg.CosNaming.NamingContextPackage,org.omg.Dynamic,org.omg.DynamicAny,org.omg.DynamicAny.DynAnyFactoryPackage,org.omg.DynamicAny.DynAnyPackage,org.omg.IOP,org.omg.IOP.CodecFactoryPackage,org.omg.IOP.CodecPackage,org.omg.Messaging,org.omg.PortableInterceptor,org.omg.PortableInterceptor.ORBInitInfoPackage,org.omg.PortableServer,org.omg.PortableServer.CurrentPackage,org.omg.PortableServer.POAManagerPackage,org.omg.PortableServer.POAPackage,org.omg.PortableServer.ServantLocatorPackage,org.omg.PortableServer.portable,org.omg.SendingContext,org.omg.stub.java.rmi,org.w3c.dom,org.w3c.dom.bootstrap,org.w3c.dom.css,org.w3c.dom.events,org.w3c.dom.html,org.w3c.dom.ls,org.w3c.dom.ranges,org.w3c.dom.stylesheets,org.w3c.dom.traversal,org.w3c.dom.views,org.xml.sax,org.xml.sax.ext,org.xml.sax.helpers"),
// Specs
mavenBundle("org.osgi", "org.osgi.compendium"),
mavenBundle("org.apache.geronimo.specs", "geronimo-annotation_1.1_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-ejb_3.1_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-jcdi_1.0_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-el_2.2_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-jaxrpc_1.1_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-servlet_3.0_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-jsp_2.2_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-interceptor_1.1_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-saaj_1.3_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-activation_1.1_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-j2ee-management_1.1_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-jpa_2.0_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-j2ee-connector_1.6_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-jacc_1.4_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-validation_1.0_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-jaxrs_1.1_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-ws-metadata_2.0_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-jaspic_1.0_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-jaxb_2.2_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-stax-api_1.2_spec").versionAsInProject(),
mavenBundle("org.apache.geronimo.specs", "geronimo-jaxws_2.2_spec").versionAsInProject(),
mavenBundle("commons-cli", "commons-cli").versionAsInProject(),
mavenBundle("org.apache.commons", "commons-lang3").versionAsInProject(),
mavenBundle("commons-lang", "commons-lang").versionAsInProject(),
mavenBundle("commons-beanutils", "commons-beanutils").versionAsInProject(),
mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.commons-collections").versionAsInProject(),
mavenBundle("org.apache.aries", "org.apache.aries.util").versionAsInProject(),
mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy").versionAsInProject(),
mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint").versionAsInProject(),
mavenBundle("org.ow2.asm", "asm-all").versionAsInProject(),
mavenBundle("org.apache.aries.application", "org.apache.aries.application.api").versionAsInProject(),
mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller").versionAsInProject(),
mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils").versionAsInProject(),
mavenBundle("org.apache.aries.ejb", "org.apache.aries.ejb.modeller").versionAsInProject(),
mavenBundle("org.apache.openejb", "openejb-core").versionAsInProject(),
mavenBundle("org.apache.openejb", "openejb-api").versionAsInProject(),
mavenBundle("org.apache.openejb", "openejb-javaagent").versionAsInProject(),
mavenBundle("org.apache.openejb", "openejb-jee").versionAsInProject(),
mavenBundle("org.apache.openejb", "openejb-loader").versionAsInProject(),
mavenBundle("org.apache.openwebbeans", "openwebbeans-impl").versionAsInProject(),
mavenBundle("org.apache.openwebbeans", "openwebbeans-spi").versionAsInProject(),
mavenBundle("org.apache.openwebbeans", "openwebbeans-ee").versionAsInProject(),
mavenBundle("org.apache.openwebbeans", "openwebbeans-ejb").versionAsInProject(),
mavenBundle("org.apache.openwebbeans", "openwebbeans-web").versionAsInProject(),
mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.javassist").versionAsInProject(),
mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.wsdl4j-1.6.1").versionAsInProject(),
mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.jaxb-impl").versionAsInProject(),
mavenBundle("org.apache.geronimo.components", "geronimo-connector").versionAsInProject(),
mavenBundle("org.apache.geronimo.components", "geronimo-transaction").versionAsInProject(),
mavenBundle("org.apache.geronimo.bundles", "scannotation").versionAsInProject(),
mavenBundle("org.apache.xbean", "xbean-asm-shaded").versionAsInProject(),
mavenBundle("org.apache.xbean", "xbean-finder-shaded").versionAsInProject(),
mavenBundle("org.apache.xbean", "xbean-naming").versionAsInProject(),
mavenBundle("org.apache.xbean", "xbean-reflect").versionAsInProject(),
mavenBundle("org.hsqldb", "hsqldb").versionAsInProject()
);
// vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"),
// waitForFrameworkStartup(),
}
}
| 9,031 |
0 | Create_ds/aries/ejb/ejb-modeller-itest/src/test/java/org/apache/aries/ejb/container | Create_ds/aries/ejb/ejb-modeller-itest/src/test/java/org/apache/aries/ejb/container/itest/ApplicationStandaloneModellerTest.java | /* 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.aries.ejb.container.itest;
import org.junit.Before;
import org.apache.aries.application.modelling.impl.ModellingManagerImpl;
import org.apache.aries.application.modelling.standalone.OfflineModellingFactory;
public class ApplicationStandaloneModellerTest extends AbstractEJBModellerTest {
@Before
public void setup() {
mrm = OfflineModellingFactory.getModelledResourceManager();
mm = new ModellingManagerImpl();
}
}
| 9,032 |
0 | Create_ds/aries/ejb/ejb-modeller-itest/src/test/java/org/apache/aries/ejb/container | Create_ds/aries/ejb/ejb-modeller-itest/src/test/java/org/apache/aries/ejb/container/itest/AbstractEJBModellerTest.java | /* 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.aries.ejb.container.itest;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import org.apache.aries.application.modelling.ExportedService;
import org.apache.aries.application.modelling.ModelledResource;
import org.apache.aries.application.modelling.ModelledResourceManager;
import org.apache.aries.application.modelling.ModellerException;
import org.apache.aries.application.modelling.ModellingManager;
import org.apache.aries.itest.AbstractIntegrationTest;
import org.apache.aries.util.filesystem.FileSystem;
import org.apache.aries.util.filesystem.ICloseableDirectory;
import org.apache.aries.util.io.IOUtils;
import org.junit.Test;
public abstract class AbstractEJBModellerTest extends AbstractIntegrationTest
{
protected ModelledResourceManager mrm;
protected ModellingManager mm;
@Test
public void modelBasicEJBBundleWithXML() throws Exception {
ModelledResource mr = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "MANIFEST_1.MF", "META-INF/MANIFEST.MF");
addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
zos.close();
mr = model(baos.toByteArray());
Collection<? extends ExportedService> services =
mr.getExportedServices();
assertEquals("Wrong number of services", 2, services.size());
assertTrue(services.containsAll(getXMLservices()));
assertTrue(Collections.disjoint(services, getAnnotatedservices()));
}
@Test
public void testEJBJARAndAnnotatedInZip() throws Exception {
ModelledResource mr = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "MANIFEST_1.MF", "META-INF/MANIFEST.MF");
addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
addToZip(zos, "beans/StatelessSessionBean.class");
addToZip(zos, "beans/StatefulSessionBean.class");
zos.close();
mr = model(baos.toByteArray());
Collection<? extends ExportedService> services =
mr.getExportedServices();
assertEquals("Wrong number of services", 3, services.size());
assertTrue(services.containsAll(getXMLservices()));
assertTrue(services.containsAll(getAnnotatedservices()));
}
@Test
public void testAnnotatedOnlyInZip() throws Exception {
ModelledResource mr = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "MANIFEST_1.MF", "META-INF/MANIFEST.MF");
addToZip(zos, "beans/StatelessSessionBean.class");
addToZip(zos, "beans/StatefulSessionBean.class");
zos.close();
mr = model(baos.toByteArray());
Collection<? extends ExportedService> services =
mr.getExportedServices();
assertEquals("Wrong number of services", 1, services.size());
assertTrue(Collections.disjoint(services, getXMLservices()));
assertTrue(services.containsAll(getAnnotatedservices()));
}
@Test
public void testEJBJARAndAnnotatedNotOnClasspathInZip() throws Exception {
ModelledResource mr = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "MANIFEST_2.MF", "META-INF/MANIFEST.MF");
addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
addToZip(zos, "beans/StatelessSessionBean.class", "no/beans/StatelessSessionBean.class");
addToZip(zos, "beans/StatefulSessionBean.class", "no/beans/StatefulSessionBean.class");
zos.close();
mr = model(baos.toByteArray());
Collection<? extends ExportedService> services =
mr.getExportedServices();
assertEquals("Wrong number of services", 2, services.size());
assertTrue(services.containsAll(getXMLservices()));
assertTrue(Collections.disjoint(services, getAnnotatedservices()));
}
@Test
public void testEJBJARAndAnnotatedOnClasspathInZip() throws Exception {
ModelledResource mr = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "MANIFEST_2.MF", "META-INF/MANIFEST.MF");
addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
addToZip(zos, "beans/StatelessSessionBean.class", "yes/beans/StatelessSessionBean.class");
addToZip(zos, "beans/StatefulSessionBean.class", "yes/beans/StatefulSessionBean.class");
zos.close();
mr = model(baos.toByteArray());
Collection<? extends ExportedService> services =
mr.getExportedServices();
assertEquals("Wrong number of services", 3, services.size());
assertTrue(services.containsAll(getXMLservices()));
assertTrue(services.containsAll(getAnnotatedservices()));
}
@Test
public void testEJBJARInWebZip() throws Exception {
ModelledResource mr = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "MANIFEST_3.MF", "META-INF/MANIFEST.MF");
addToZip(zos, "ejb-jar.xml", "WEB-INF/ejb-jar.xml");
zos.close();
mr = model(baos.toByteArray());
Collection<? extends ExportedService> services =
mr.getExportedServices();
assertEquals("Wrong number of services", 2, services.size());
assertTrue(services.containsAll(getXMLservices()));
assertTrue(Collections.disjoint(services, getAnnotatedservices()));
}
@Test
public void testEJBJARInWrongPlaceWebZip() throws Exception {
ModelledResource mr = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "MANIFEST_3.MF", "META-INF/MANIFEST.MF");
addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
zos.close();
mr = model(baos.toByteArray());
Collection<? extends ExportedService> services =
mr.getExportedServices();
assertEquals("Wrong number of services", 0, services.size());
}
@Test
public void testEJBJARAndAnnotatedInWebZip() throws Exception {
ModelledResource mr = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "MANIFEST_3.MF", "META-INF/MANIFEST.MF");
addToZip(zos, "ejb-jar.xml", "WEB-INF/ejb-jar.xml");
addToZip(zos, "beans/StatelessSessionBean.class");
addToZip(zos, "beans/StatefulSessionBean.class");
zos.close();
mr = model(baos.toByteArray());
Collection<? extends ExportedService> services =
mr.getExportedServices();
assertEquals("Wrong number of services", 3, services.size());
assertTrue(services.containsAll(getXMLservices()));
assertTrue(services.containsAll(getAnnotatedservices()));
}
@Test
public void testAnnotatedOnlyInWebZip() throws Exception {
ModelledResource mr = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "MANIFEST_3.MF", "META-INF/MANIFEST.MF");
addToZip(zos, "beans/StatelessSessionBean.class");
addToZip(zos, "beans/StatefulSessionBean.class");
zos.close();
mr = model(baos.toByteArray());
Collection<? extends ExportedService> services =
mr.getExportedServices();
assertEquals("Wrong number of services", 1, services.size());
assertTrue(Collections.disjoint(services, getXMLservices()));
assertTrue(services.containsAll(getAnnotatedservices()));
}
@Test
public void testEJBJARAndAnnotatedNotOnClasspathInWebZip() throws Exception {
ModelledResource mr = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "MANIFEST_4.MF", "META-INF/MANIFEST.MF");
addToZip(zos, "ejb-jar.xml", "WEB-INF/ejb-jar.xml");
addToZip(zos, "beans/StatelessSessionBean.class", "no/beans/StatelessSessionBean.class");
addToZip(zos, "beans/StatefulSessionBean.class", "no/beans/StatefulSessionBean.class");
zos.close();
mr = model(baos.toByteArray());
Collection<? extends ExportedService> services =
mr.getExportedServices();
assertEquals("Wrong number of services", 2, services.size());
assertTrue(services.containsAll(getXMLservices()));
assertTrue(Collections.disjoint(services, getAnnotatedservices()));
}
@Test
public void testEJBJARAndAnnotatedOnClasspathInWebZip() throws Exception {
ModelledResource mr = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addToZip(zos, "MANIFEST_4.MF", "META-INF/MANIFEST.MF");
addToZip(zos, "ejb-jar.xml", "WEB-INF/ejb-jar.xml");
addToZip(zos, "beans/StatelessSessionBean.class", "yes/beans/StatelessSessionBean.class");
addToZip(zos, "beans/StatefulSessionBean.class", "yes/beans/StatefulSessionBean.class");
zos.close();
mr = model(baos.toByteArray());
Collection<? extends ExportedService> services =
mr.getExportedServices();
assertEquals("Wrong number of services", 3, services.size());
assertTrue(services.containsAll(getXMLservices()));
assertTrue(services.containsAll(getAnnotatedservices()));
}
private ModelledResource model(byte[] bytes) throws ModellerException {
ICloseableDirectory dir = null;
try {
dir = FileSystem.getFSRoot(
new ByteArrayInputStream(bytes));
return mrm.getModelledResource(dir);
} finally {
IOUtils.close(dir);
}
}
private Collection<ExportedService> getXMLservices() {
Map<String, Object> serviceProperties = new HashMap<String, Object>();
serviceProperties.put("ejb.name", "XML");
serviceProperties.put("ejb.type", "Singleton");
serviceProperties.put("service.exported.interfaces", "remote.Iface");
Map<String, Object> serviceProperties2 = new HashMap<String, Object>();
serviceProperties2.put("ejb.name", "XML");
serviceProperties2.put("ejb.type", "Singleton");
return Arrays.asList(mm.getExportedService("XML", 0,
Arrays.asList("remote.Iface"), serviceProperties), mm.getExportedService(
"XML", 0, Arrays.asList("local.Iface"), serviceProperties2));
}
private Collection<ExportedService> getAnnotatedservices() {
Map<String, Object> serviceProperties = new HashMap<String, Object>();
serviceProperties.put("ejb.name", "Annotated");
serviceProperties.put("ejb.type", "Stateless");
return Arrays.asList(mm.getExportedService("Annotated", 0,
Arrays.asList("beans.StatelessSessionBean"), serviceProperties));
}
private void addToZip(ZipOutputStream zos, String src) throws IOException {
addToZip(zos, src, src);
}
private void addToZip(ZipOutputStream zos, String src, String outLocation) throws IOException {
zos.putNextEntry(new ZipEntry(outLocation));
IOUtils.copy(getClass().getClassLoader().
getResourceAsStream(src), zos);
zos.closeEntry();
}
}
| 9,033 |
0 | Create_ds/aries/ejb/ejb-modeller-itest/src/test/java | Create_ds/aries/ejb/ejb-modeller-itest/src/test/java/beans/StatefulSessionBean.java | /**
* 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 beans;
import javax.ejb.Stateful;
@Stateful(name="Stateful")
public class StatefulSessionBean {
}
| 9,034 |
0 | Create_ds/aries/ejb/ejb-modeller-itest/src/test/java | Create_ds/aries/ejb/ejb-modeller-itest/src/test/java/beans/StatelessSessionBean.java | /**
* 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 beans;
import javax.ejb.Stateless;
@Stateless(name="Annotated")
public class StatelessSessionBean {
}
| 9,035 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/ServiceMetadata.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
import java.util.Collection;
import java.util.List;
/**
* Metadata for a service to be registered by the Blueprint Container when
* enabled.
*
* <p>
* This is specified by the <code>service</code> element.
*
* @ThreadSafe
* @version $Revision$
*/
public interface ServiceMetadata extends ComponentMetadata {
/**
* Do not auto-detect types for advertised service interfaces
*
* @see #getAutoExport()
*/
static final int AUTO_EXPORT_DISABLED = 1;
/**
* Advertise all Java interfaces implemented by the component instance type
* as service interfaces.
*
* @see #getAutoExport()
*/
static final int AUTO_EXPORT_INTERFACES = 2;
/**
* Advertise all Java classes in the hierarchy of the component instance
* type as service interfaces.
*
* @see #getAutoExport()
*/
static final int AUTO_EXPORT_CLASS_HIERARCHY = 3;
/**
* Advertise all Java classes and interfaces in the component instance type
* as service interfaces.
*
* @see #getAutoExport()
*/
static final int AUTO_EXPORT_ALL_CLASSES = 4;
/**
* Return the Metadata for the component to be exported as a service.
*
* This is specified inline or via the <code>ref</code> attribute of the
* service.
*
* @return The Metadata for the component to be exported as a service.
*/
Target getServiceComponent();
/**
* Return the type names of the interfaces that the service should be
* advertised as supporting.
*
* This is specified in the <code>interface</code> attribute or child
* <code>interfaces</code> element of the service.
*
* @return An immutable List of <code>String</code> for the type names of
* the interfaces that the service should be advertised as
* supporting. The List is empty if using <code>auto-export</code>
* or no interface names are specified for the service.
*/
List<String> getInterfaces();
/**
* Return the auto-export mode for the service.
*
* This is specified by the <code>auto-export</code> attribute of the
* service.
*
* @return The auto-export mode for the service.
* @see #AUTO_EXPORT_DISABLED
* @see #AUTO_EXPORT_INTERFACES
* @see #AUTO_EXPORT_CLASS_HIERARCHY
* @see #AUTO_EXPORT_ALL_CLASSES
*/
int getAutoExport();
/**
* Return the user declared properties to be advertised with the service.
*
* This is specified by the <code>service-properties</code> element of the
* service.
*
* @return An immutable List of {@link MapEntry} objects for the user
* declared properties to be advertised with the service. The List
* is empty if no service properties are specified for the service.
*/
List<MapEntry> getServiceProperties();
/**
* Return the ranking value to use when advertising the service. If the
* ranking value is zero, the service must be registered without a
* <code>service.ranking</code> service property.
*
* This is specified by the <code>ranking</code> attribute of the service.
*
* @return The ranking value to use when advertising the service.
*/
int getRanking();
/**
* Return the registration listeners to be notified when the service is
* registered and unregistered with the framework.
*
* This is specified by the <code>registration-listener</code> elements of
* the service.
*
* @return An immutable Collection of {@link RegistrationListener} objects
* to be notified when the service is registered and unregistered
* with the framework. The Collection is empty if no registration
* listeners are specified for the service.
*/
Collection<RegistrationListener> getRegistrationListeners();
}
| 9,036 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/BeanMetadata.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
import java.util.List;
/**
* Metadata for a Bean component.
*
* <p>
* This is specified by the <code>bean</code> element.
*
* @ThreadSafe
* @version $Revision$
*/
public interface BeanMetadata extends Target, ComponentMetadata {
/**
* The bean has <code>singleton</code> scope.
*
* @see #getScope()
*/
static final String SCOPE_SINGLETON = "singleton";
/**
* The bean has <code>prototype</code> scope.
*
* @see #getScope()
*/
static final String SCOPE_PROTOTYPE = "prototype";
/**
* Return the name of the class specified for the bean.
*
* This is specified by the <code>class</code> attribute of the bean
* definition.
*
* @return The name of the class specified for the bean. If no class is
* specified in the bean definition, because the a factory component
* is used instead, then this method will return <code>null</code>.
*/
String getClassName();
/**
* Return the name of the init method specified for the bean.
*
* This is specified by the <code>init-method</code> attribute of the bean
* definition.
*
* @return The name of the init method specified for the bean, or
* <code>null</code> if no init method is specified.
*/
String getInitMethod();
/**
* Return the name of the destroy method specified for the bean.
*
* This is specified by the <code>destroy-method</code> attribute of the
* bean definition.
*
* @return The name of the destroy method specified for the bean, or
* <code>null</code> if no destroy method is specified.
*/
String getDestroyMethod();
/**
* Return the arguments for the factory method or constructor of the bean.
*
* This is specified by the child <code>argument<code> elements.
*
* @return An immutable List of {@link BeanArgument} objects for the factory
* method or constructor of the bean. The List is empty if no
* arguments are specified for the bean.
*/
List<BeanArgument> getArguments();
/**
* Return the properties for the bean.
*
* This is specified by the child <code>property</code> elements.
*
* @return An immutable List of {@link BeanProperty} objects, with one entry
* for each property to be injected in the bean. The List is empty
* if no property injection is specified for the bean.
*
*/
List<BeanProperty> getProperties();
/**
* Return the name of the factory method for the bean.
*
* This is specified by the <code>factory-method</code> attribute of the
* bean.
*
* @return The name of the factory method of the bean or <code>null</code>
* if no factory method is specified for the bean.
*/
String getFactoryMethod();
/**
* Return the Metadata for the factory component on which to invoke the
* factory method for the bean.
*
* This is specified by the <code>factory-ref</code> attribute of the bean.
*
* <p>
* When a factory method and factory component have been specified for the
* bean, this method returns the factory component on which to invoke the
* factory method for the bean. When no factory component has been specified
* this method will return <code>null</code>.
*
* When a factory method has been specified for the bean but a factory
* component has not been specified, the factory method must be invoked as a
* static method on the bean's class.
*
* @return The Metadata for the factory component on which to invoke the
* factory method for the bean or <code>null</code> if no factory
* component is specified.
*/
Target getFactoryComponent();
/**
* Return the scope for the bean.
*
* @return The scope for the bean.
* @see #SCOPE_SINGLETON
* @see #SCOPE_PROTOTYPE
*/
String getScope();
}
| 9,037 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/CollectionMetadata.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
import java.util.List;
/**
* Metadata for a collection based value. Values of the collection are defined
* by Metadata objects. This Collection Metadata can constrain the values of the
* collection to a specific type.
*
* @ThreadSafe
* @version $Revision$
*/
public interface CollectionMetadata extends NonNullMetadata {
/**
* Return the type of the collection.
*
* The possible types are: array (<code>Object[]</code>), <code>Set</code>,
* and <code>List</code>. This information is specified in the element name.
*
* @return The type of the collection. <code>Object[]</code> is returned to
* indicate an array.
*/
Class<?> getCollectionClass();
/**
* Return the type specified for the values of the collection.
*
* The <code>value-type</code> attribute specified this information.
*
* @return The type specified for the values of the collection.
*/
String getValueType();
/**
* Return Metadata for the values of the collection.
*
* @return A List of Metadata for the values of the collection.
*/
List<Metadata> getValues();
}
| 9,038 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/IdRefMetadata.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
/**
* Metadata for the verified id of another component managed by the Blueprint
* Container. The id itself will be injected, not the component to which the id
* refers. No implicit dependency is created.
*
* @ThreadSafe
* @version $Revision$
*/
public interface IdRefMetadata extends NonNullMetadata {
/**
* Return the id of the referenced component.
*
* This is specified by the <code>component-id</code> attribute of a
* component.
*
* @return The id of the referenced component.
*/
String getComponentId();
}
| 9,039 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/ServiceReferenceMetadata.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
import java.util.Collection;
/**
* Metadata for a reference to an OSGi service. This is the base type for
* {@link ReferenceListMetadata} and {@link ReferenceMetadata}.
*
* @ThreadSafe
* @version $Revision$
*/
public interface ServiceReferenceMetadata extends ComponentMetadata {
/**
* A matching service is required at all times.
*
* @see #getAvailability()
*/
static final int AVAILABILITY_MANDATORY = 1;
/**
* A matching service is not required to be present.
*
* @see #getAvailability()
*/
static final int AVAILABILITY_OPTIONAL = 2;
/**
* Return whether or not a matching service is required at all times.
*
* This is specified in the <code>availability</code> attribute of the
* service reference.
*
* @return Whether or not a matching service is required at all times.
* @see #AVAILABILITY_MANDATORY
* @see #AVAILABILITY_OPTIONAL
*/
int getAvailability();
/**
* Return the name of the interface type that a matching service must
* support.
*
* This is specified in the <code>interface</code> attribute of the service
* reference.
*
* @return The name of the interface type that a matching service must
* support or <code>null</code> when no interface name is specified.
*/
String getInterface();
/**
* Return the value of the <code>component-name</code> attribute of the
* service reference. This specifies the id of a component that is
* registered in the service registry. This will create an automatic filter,
* appended with the filter if set, to select this component based on its
* automatic <code>id</code> attribute.
*
* @return The value of the <code>component-name</code> attribute of the
* service reference or <code>null</code> if the attribute is not
* specified.
*/
String getComponentName();
/**
* Return the filter expression that a matching service must match.
*
* This is specified by the <code>filter</code> attribute of the service
* reference.
*
* @return The filter expression that a matching service must match or
* <code>null</code> if a filter is not specified.
*/
String getFilter();
/**
* Return the reference listeners to receive bind and unbind events.
*
* This is specified by the <code>reference-listener</code> elements of the
* service reference.
*
* @return An immutable Collection of {@link ReferenceListener} objects to
* receive bind and unbind events. The Collection is empty if no
* reference listeners are specified for the service reference.
*/
Collection<ReferenceListener> getReferenceListeners();
}
| 9,040 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/ReferenceListMetadata.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
/**
* Metadata for a list of service references.
*
* <p>
* This is specified by the <code>reference-list</code> element.
*
* @ThreadSafe
* @version $Revision$
*/
public interface ReferenceListMetadata extends ServiceReferenceMetadata {
/**
* Reference list values must be proxies to the actual service objects.
*
* @see #getMemberType()
*/
static final int USE_SERVICE_OBJECT = 1;
/**
* Reference list values must be <code>ServiceReference</code> objects.
*
* @see #getMemberType()
*/
static final int USE_SERVICE_REFERENCE = 2;
/**
* Return whether the List will contain service object proxies or
* <code>ServiceReference</code> objects.
*
* This is specified by the <code>member-type</code> attribute of the
* reference list.
*
* @return Whether the List will contain service object proxies or
* <code>ServiceReference</code> objects.
* @see #USE_SERVICE_OBJECT
* @see #USE_SERVICE_REFERENCE
*/
int getMemberType();
}
| 9,041 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/ValueMetadata.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
/**
* Metadata for a simple <code>String</code> value that will be type-converted
* if necessary before injecting.
*
* @ThreadSafe
* @version $Revision$
*/
public interface ValueMetadata extends NonNullMetadata {
/**
* Return the unconverted string representation of the value.
*
* This is specified by the <code>value</code> attribute or text part of the
* <code>value</code> element.
*
* @return The unconverted string representation of the value.
*/
String getStringValue();
/**
* Return the name of the type to which the value should be converted.
*
* This is specified by the <code>type</code> attribute.
*
* @return The name of the type to which the value should be converted or
* <code>null</code> if no type is specified.
*/
String getType();
}
| 9,042 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/RegistrationListener.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
/**
* Metadata for a registration listener interested in service registration and
* unregistration events for a service.
*
* <p>
* The registration listener is called with the initial state of the service
* when the registration listener is actuated.
*
* @ThreadSafe
* @version $Revision$
*/
public interface RegistrationListener {
/**
* Return the Metadata for the component that will receive registration and
* unregistration events.
*
* This is specified by the <code>ref</code> attribute or via an inlined
* component.
*
* @return The Metadata for the component that will receive registration and
* unregistration events.
*/
Target getListenerComponent();
/**
* Return the name of the registration method. The registration method will
* be invoked when the associated service is registered with the service
* registry.
*
* This is specified by the <code>registration-method</code> attribute of
* the registration listener.
*
* @return The name of the registration method.
*/
String getRegistrationMethod();
/**
* Return the name of the unregistration method. The unregistration method
* will be invoked when the associated service is unregistered from the
* service registry.
*
* This is specified by the <code>unregistration-method</code> attribute of
* the registration listener.
*
* @return The name of the unregistration method.
*/
String getUnregistrationMethod();
}
| 9,043 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/BeanArgument.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
/**
* Metadata for a factory method or constructor argument of a bean. The
* arguments of a bean are obtained from {@link BeanMetadata#getArguments()}.
*
* This is specified by the <code>argument</code> elements of a bean.
*
* @ThreadSafe
* @version $Revision$
*/
public interface BeanArgument {
/**
* Return the Metadata for the argument value.
*
* This is specified by the <code>value</code> attribute.
*
* @return The Metadata for the argument value.
*/
Metadata getValue();
/**
* Return the name of the value type to match the argument and convert the
* value into when invoking the constructor or factory method.
*
* This is specified by the <code>type</code> attribute.
*
* @return The name of the value type to convert the value into, or
* <code>null</code> if no type is specified.
*/
String getValueType();
/**
* Return the zero-based index into the parameter list of the factory method
* or constructor to be invoked for this argument. This is determined by
* specifying the <code>index</code> attribute for the bean. If not
* explicitly set, this will return -1 and the initial ordering is defined
* by its position in the {@link BeanMetadata#getArguments()} list.
*
* This is specified by the <code>index</code> attribute.
*
* @return The zero-based index of the parameter, or -1 if no index is
* specified.
*/
int getIndex();
}
| 9,044 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/RefMetadata.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
/**
* Metadata for a reference to another component managed by the Blueprint
* Container.
*
* @ThreadSafe
* @version $Revision$
*/
public interface RefMetadata extends Target, NonNullMetadata {
/**
* Return the id of the referenced component.
*
* This is specified by the <code>component-id</code> attribute of a
* component.
*
* @return The id of the referenced component.
*/
String getComponentId();
}
| 9,045 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/MapMetadata.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
import java.util.List;
/**
* Metadata for a Map based value.
*
* <p>
* This is specified by the <code>map</code> element.
*
* @ThreadSafe
* @version $Revision$
*/
public interface MapMetadata extends NonNullMetadata {
/**
* Return the name of the type of the map keys.
*
* This is specified by the <code>key-type</code> attribute of the map.
*
* @return The name of the type of the map keys, or <code>null</code> if
* none is specified.
*/
String getKeyType();
/**
* Return the name of the type of the map values.
*
* This is specified by the <code>value-type</code> attribute of the map.
*
* @return The name of the type of the map values, or <code>null</code> if
* none is specified.
*/
String getValueType();
/**
* Return the entries for the map.
*
* @return An immutable List of {@link MapEntry} objects for each entry in
* the map. The List is empty if no entries are specified for the
* map.
*/
List<MapEntry> getEntries();
}
| 9,046 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/Metadata.java | /*
* Copyright (c) OSGi Alliance (2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
/**
* Top level Metadata type. All Metdata types extends this base type.
*
* @ThreadSafe
* @version $Revision$
*/
public interface Metadata {
// marker interface
}
| 9,047 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/MapEntry.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
/**
* Metadata for a map entry.
*
* This type is used by {@link MapMetadata}, {@link PropsMetadata} and
* {@link ServiceMetadata}.
*
* @ThreadSafe
* @version $Revision$
*/
public interface MapEntry {
/**
* Return the Metadata for the key of the map entry.
*
* This is specified by the <code>key</code> attribute or element.
*
* @return The Metadata for the key of the map entry. This must not be
* <code>null</code>.
*/
NonNullMetadata getKey();
/**
* Return the Metadata for the value of the map entry.
*
* This is specified by the <code>value</code> attribute or element.
*
* @return The Metadata for the value of the map entry. This must not be
* <code>null</code>.
*/
Metadata getValue();
}
| 9,048 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/ReferenceListener.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
/**
* Metadata for a reference listener interested in the reference bind and unbind
* events for a service reference.
*
* @ThreadSafe
* @version $Revision$
*/
public interface ReferenceListener {
/**
* Return the Metadata for the component that will receive bind and unbind
* events.
*
* This is specified by the <code>ref</code> attribute or via an inlined
* component.
*
* @return The Metadata for the component that will receive bind and unbind
* events.
*/
Target getListenerComponent();
/**
* Return the name of the bind method. The bind method will be invoked when
* a matching service is bound to the reference.
*
* This is specified by the <code>bind-method</code> attribute of the
* reference listener.
*
* @return The name of the bind method.
*/
String getBindMethod();
/**
* Return the name of the unbind method. The unbind method will be invoked
* when a matching service is unbound from the reference.
*
* This is specified by the <code>unbind-method</code> attribute of the
* reference listener.
*
* @return The name of the unbind method.
*/
String getUnbindMethod();
}
| 9,049 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/NullMetadata.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
/**
* Metadata for a value specified to be <code>null</code> via the <null>
* element.
*
* @ThreadSafe
* @version $Revision$
*/
public interface NullMetadata extends Metadata {
/**
* Singleton instance of <code>NullMetadata</code>.
*/
static final NullMetadata NULL = new NullMetadata() {
// empty body
};
}
| 9,050 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/PropsMetadata.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
import java.util.List;
/**
* Metadata for a <code>java.util.Properties</code> based value.
*
* <p>
* The {@link MapEntry} objects of properties are defined with keys and values
* of type <code>String</code>.
*
* <p>
* This is specified by the <code>props</code> element.
*
* @ThreadSafe
* @version $Revision$
*/
public interface PropsMetadata extends NonNullMetadata {
/**
* Return the entries for the properties.
*
* @return An immutable List of {@link MapEntry} objects for each entry in
* the properties. The List is empty if no entries are specified for
* the properties.
*/
List<MapEntry> getEntries();
}
| 9,051 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/BeanProperty.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
/**
* Metadata for a property to be injected into a bean. The properties of a bean
* are obtained from {@link BeanMetadata#getProperties()}.
*
* This is specified by the <code>property</code> elements of a bean. Properties
* are defined according to the Java Beans conventions.
*
* @ThreadSafe
* @version $Revision$
*/
public interface BeanProperty {
/**
* Return the name of the property to be injected. The name follows Java
* Beans conventions.
*
* This is specified by the <code>name</code> attribute.
*
* @return The name of the property to be injected.
*/
String getName();
/**
* Return the Metadata for the value to be injected into a bean.
*
* This is specified by the <code>value</code> attribute or in inlined text.
*
* @return The Metadata for the value to be injected into a bean.
*/
Metadata getValue();
}
| 9,052 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/NonNullMetadata.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
/**
* Metadata for a value that cannot <code>null</code>. All Metadata subtypes
* extend this type except for {@link NullMetadata}.
*
* <p>
* This Metadata type is used for keys in Maps because they cannot be
* <code>null</code>.
*
* @ThreadSafe
* @version $Revision$
*/
public interface NonNullMetadata extends Metadata {
// marker interface
}
| 9,053 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/Target.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
/**
* A common interface for managed components that can be used as a direct target
* for method calls. These are <code>bean</code>, <code>reference</code>, and
* <code>ref</code>, where the <code>ref</code> must refer to a bean or
* reference component.
*
* @see BeanMetadata
* @see ReferenceMetadata
* @see RefMetadata
* @ThreadSafe
* @version $Revision$
*/
public interface Target extends NonNullMetadata {
// marker interface
}
| 9,054 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/ComponentMetadata.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
import java.util.List;
/**
* Metadata for managed components. This is the base type for
* {@link BeanMetadata}, {@link ServiceMetadata} and
* {@link ServiceReferenceMetadata}.
*
* @ThreadSafe
* @version $Revision$
*/
public interface ComponentMetadata extends NonNullMetadata {
/**
* The component's manager must eagerly activate the component.
*
* @see #getActivation()
*/
static final int ACTIVATION_EAGER = 1;
/**
* The component's manager must lazily activate the component.
*
* @see #getActivation()
*/
static final int ACTIVATION_LAZY = 2;
/**
* Return the id of the component.
*
* @return The id of the component. The component id can be
* <code>null</code> if this is an anonymously defined and/or
* inlined component.
*/
String getId();
/**
* Return the activation strategy for the component.
*
* This is specified by the <code>activation</code> attribute of a component
* definition. If this is not set, then the <code>default-activation</code>
* in the <code>blueprint</code> element is used. If that is also not set,
* then the activation strategy is {@link #ACTIVATION_EAGER}.
*
* @return The activation strategy for the component.
* @see #ACTIVATION_EAGER
* @see #ACTIVATION_LAZY
*/
int getActivation();
/**
* Return the ids of any components listed in a <code>depends-on</code>
* attribute for the component.
*
* @return An immutable List of component ids that are explicitly declared
* as a dependency, or an empty List if none.
*/
List<String> getDependsOn();
}
| 9,055 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/reflect/ReferenceMetadata.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.reflect;
/**
* Metadata for a reference that will bind to a single matching service in the
* service registry.
*
* <p>
* This is specified by the <code>reference</code> element.
*
* @ThreadSafe
* @version $Revision$
*/
public interface ReferenceMetadata extends Target, ServiceReferenceMetadata {
/**
* Return the timeout for service invocations when a backing service is is
* unavailable.
*
* This is specified by the <code>timeout</code> attribute of the reference.
*
* @return The timeout, in milliseconds, for service invocations when a
* backing service is is unavailable.
*/
long getTimeout();
}
| 9,056 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/ServiceUnavailableException.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.container;
import org.osgi.framework.ServiceException;
/**
* A Blueprint exception indicating that a service is unavailable.
*
* This exception is thrown when an invocation is made on a service reference
* and a backing service is not available.
*
* @version $Revision$
*/
public class ServiceUnavailableException extends ServiceException {
private static final long serialVersionUID = 1L;
/**
* The filter string associated with the exception.
*/
private final String filter;
/**
* Creates a Service Unavailable Exception with the specified message.
*
* @param message The associated message.
* @param filter The filter used for the service lookup.
*/
public ServiceUnavailableException(String message, String filter) {
super(message, UNREGISTERED);
this.filter = filter;
}
/**
* Creates a Service Unavailable Exception with the specified message and
* exception cause.
*
* @param message The associated message.
* @param filter The filter used for the service lookup.
* @param cause The cause of this exception.
*/
public ServiceUnavailableException(String message, String filter,
Throwable cause) {
super(message, UNREGISTERED, cause);
this.filter = filter;
}
/**
* Returns the filter expression that a service would have needed to satisfy
* in order for the invocation to proceed.
*
* @return The failing filter.
*/
public String getFilter() {
return this.filter;
}
}
| 9,057 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/ReifiedType.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.container;
/**
* Provides access to a concrete type and its optional generic type parameters.
*
* <p>
* Java 5 and later support generic types. These types consist of a raw class
* with type parameters. This class models such a <code>Type</code> class but
* ensures that the type is <em>reified</em>. Reification means that the Type
* graph associated with a Java 5 <code>Type</code> instance is traversed until
* the type becomes a concrete class. This class is available with the
* {@link #getRawClass()} method. The optional type parameters are recursively
* represented as Reified Types.
*
* <p>
* In Java 1.4, a class has by definition no type parameters. This class
* implementation provides the Reified Type for Java 1.4 by making the raw class
* the Java 1.4 class and using a Reified Type based on the <code>Object</code>
* class for any requested type parameter.
*
* <p>
* A Blueprint extender implementations can subclass this class and provide
* access to the generic type parameter graph for conversion. Such a subclass
* must <em>reify</em> the different Java 5 <code>Type</code> instances into the
* reified form. That is, a form where the raw Class is available with its
* optional type parameters as Reified Types.
*
* @Immutable
* @version $Revision$
*/
public class ReifiedType {
private final static ReifiedType OBJECT = new ReifiedType(Object.class);
private final Class clazz;
/**
* Create a Reified Type for a raw Java class without any generic type
* parameters. Subclasses can provide the optional generic type parameter
* information. Without subclassing, this instance has no type parameters.
*
* @param clazz The raw class of the Reified Type.
*/
public ReifiedType(Class clazz) {
this.clazz = clazz;
}
/**
* Return the raw class represented by this type.
*
* The raw class represents the concrete class that is associated with a
* type declaration. This class could have been deduced from the generics
* type parameter graph of the declaration. For example, in the following
* example:
*
* <pre>
* Map<String, ? extends Metadata>
* </pre>
*
* The raw class is the Map class.
*
* @return The raw class represented by this type.
*/
public Class getRawClass() {
return clazz;
}
/**
* Return a type parameter for this type.
*
* The type parameter refers to a parameter in a generic type declaration
* given by the zero-based index <code>i</code>.
*
* For example, in the following example:
*
* <pre>
* Map<String, ? extends Metadata>
* </pre>
*
* type parameter 0 is <code>String</code>, and type parameter 1 is
* <code>Metadata</code>.
*
* <p>
* This implementation returns a Reified Type that has <code>Object</code>
* as class. Any object is assignable to Object and therefore no conversion
* is then necessary. This is compatible with versions of Java language
* prior to Java 5.
*
* This method should be overridden by a subclass that provides access to
* the generic type parameter information for Java 5 and later.
*
* @param i The zero-based index of the requested type parameter.
* @return The <code>ReifiedType</code> for the generic type parameter at
* the specified index.
*/
public ReifiedType getActualTypeArgument(int i) {
return OBJECT;
}
/**
* Return the number of type parameters for this type.
*
* <p>
* This implementation returns <code>0</code>. This method should be
* overridden by a subclass that provides access to the generic type
* parameter information for Java 5 and later.
*
* @return The number of type parameters for this type.
*/
public int size() {
return 0;
}
}
| 9,058 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintListener.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.container;
/**
* A <code>BlueprintEvent</code> Listener.
*
* <p>
* To receive Blueprint Events, a bundle must register a Blueprint Listener
* service.
*
* After a Blueprint Listener is registered, the Blueprint extender must
* synchronously send to this Blueprint Listener the last Blueprint Event for
* each ready Blueprint bundle managed by this extender. This replay of
* Blueprint Events is designed so that the new Blueprint Listener can be
* informed of the state of each Blueprint bundle. Blueprint Events sent during
* this replay will have the {@link BlueprintEvent#isReplay() isReplay()} flag
* set. The Blueprint extender must ensure that this replay phase does not
* interfere with new Blueprint Events so that the chronological order of all
* Blueprint Events received by the Blueprint Listener is preserved. If the last
* Blueprint Event for a given Blueprint bundle is
* {@link BlueprintEvent#DESTROYED DESTROYED}, the extender must not send it
* during this replay phase.
*
* @see BlueprintEvent
* @ThreadSafe
* @version $Revision$
*/
public interface BlueprintListener {
/**
* Receives notifications of a Blueprint Event.
*
* Implementers should quickly process the event and return.
*
* @param event The {@link BlueprintEvent}.
*/
void blueprintEvent(BlueprintEvent event);
}
| 9,059 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/Converter.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.container;
/**
* Type converter to convert an object to a target type.
*
* @ThreadSafe
* @version $Revision$
*/
public interface Converter {
/**
* Return if this converter is able to convert the specified object to the
* specified type.
*
* @param sourceObject The source object <code>s</code> to convert.
* @param targetType The target type <code>T</code>.
*
* @return <code>true</code> if the conversion is possible,
* <code>false</code> otherwise.
*/
boolean canConvert(Object sourceObject, ReifiedType targetType);
/**
* Convert the specified object to an instance of the specified type.
*
* @param sourceObject The source object <code>s</code> to convert.
* @param targetType The target type <code>T</code>.
* @return An instance with a type that is assignable from targetType's raw
* class
* @throws Exception If the conversion cannot succeed. This exception should
* not be thrown when the {@link #canConvert canConvert} method has
* returned <code>true</code>.
*/
Object convert(Object sourceObject, ReifiedType targetType)
throws Exception;
} | 9,060 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintContainer.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.container;
import java.util.Collection;
import java.util.Set;
import org.osgi.service.blueprint.reflect.BeanMetadata;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
import org.osgi.service.blueprint.reflect.ReferenceListMetadata;
import org.osgi.service.blueprint.reflect.ReferenceMetadata;
import org.osgi.service.blueprint.reflect.ServiceMetadata;
import org.osgi.service.blueprint.reflect.ServiceReferenceMetadata;
/**
* A Blueprint Container represents the managed state of a Blueprint bundle.
*
* A Blueprint Container provides access to all managed components. These are
* the beans, services, and service references. Only bundles in the
* <code>ACTIVE</code> state (and also the <code>STARTING</code> state for
* bundles awaiting lazy activation) can have an associated Blueprint Container.
* A given Bundle Context has at most one associated Blueprint Container.
*
* A Blueprint Container can be obtained by injecting the predefined
* "blueprintContainer" component id. The Blueprint Container is also
* registered as a service and its managed components can be queried.
*
* @ThreadSafe
* @version $Revision$
*/
public interface BlueprintContainer {
/**
* Returns the set of component ids managed by this Blueprint Container.
*
* @return An immutable Set of Strings, containing the ids of all of the
* components managed within this Blueprint Container.
*/
Set<String> getComponentIds();
/**
* Return the component instance for the specified component id.
*
* If the component's manager has not yet been activated, calling this
* operation will atomically activate it. If the component has singleton
* scope, the activation will cause the component instance to be created and
* initialized. If the component has prototype scope, then each call to this
* method will return a new component instance.
*
* @param id The component id for the requested component instance.
* @return A component instance for the component with the specified
* component id.
* @throws NoSuchComponentException If no component with the specified
* component id is managed by this Blueprint Container.
*/
Object getComponentInstance(String id);
/**
* Return the Component Metadata object for the component with the specified
* component id.
*
* @param id The component id for the requested Component Metadata.
* @return The Component Metadata object for the component with the
* specified component id.
* @throws NoSuchComponentException If no component with the specified
* component id is managed by this Blueprint Container.
*/
ComponentMetadata getComponentMetadata(String id);
/**
* Return all {@link ComponentMetadata} objects of the specified Component
* Metadata type. The supported Component Metadata types are
* {@link ComponentMetadata} (which returns the Component Metadata for all
* defined manager types), {@link BeanMetadata} ,
* {@link ServiceReferenceMetadata} (which returns both
* {@link ReferenceMetadata} and {@link ReferenceListMetadata} objects), and
* {@link ServiceMetadata}. The collection will include all Component
* Metadata objects of the requested type, including components that are
* declared inline.
*
* @param type The super type or type of the requested Component Metadata
* objects.
* @return An immutable collection of Component Metadata objects of the
* specified type.
*/
<T extends ComponentMetadata> Collection<T> getMetadata(
Class<T> type);
}
| 9,061 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintEvent.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.container;
import org.osgi.framework.Bundle;
/**
* A Blueprint Event.
*
* <p>
* <code>BlueprintEvent</code> objects are delivered to all registered
* {@link BlueprintListener} services. Blueprint Events must be asynchronously
* delivered in chronological order with respect to each listener.
*
* <p>
* In addition, after a Blueprint Listener is registered, the Blueprint extender
* will synchronously send to this Blueprint Listener the last Blueprint Event
* for each ready Blueprint bundle managed by this extender. This
* <em>replay</em> of Blueprint Events is designed so that the new Blueprint
* Listener can be informed of the state of each Blueprint bundle. Blueprint
* Events sent during this replay will have the {@link #isReplay()} flag set.
* The Blueprint extender must ensure that this replay phase does not interfere
* with new Blueprint Events so that the chronological order of all Blueprint
* Events received by the Blueprint Listener is preserved. If the last Blueprint
* Event for a given Blueprint bundle is {@link #DESTROYED}, the extender must
* not send it during this replay phase.
*
* <p>
* A type code is used to identify the type of event. The following event types
* are defined:
* <ul>
* <li>{@link #CREATING}</li>
* <li>{@link #CREATED}</li>
* <li>{@link #DESTROYING}</li>
* <li>{@link #DESTROYED}</li>
* <li>{@link #FAILURE}</li>
* <li>{@link #GRACE_PERIOD}</li>
* <li>{@link #WAITING}</li>
* </ul>
*
* <p>
* In addition to calling the registered {@link BlueprintListener} services, the
* Blueprint extender must also send those events to the Event Admin service, if
* it is available.
*
* @see BlueprintListener
* @see EventConstants
* @Immutable
* @version $Revision$
*/
public class BlueprintEvent {
/**
* The Blueprint extender has started creating a Blueprint Container for the
* bundle.
*/
public static final int CREATING = 1;
/**
* The Blueprint extender has created a Blueprint Container for the bundle.
* This event is sent after the Blueprint Container has been registered as a
* service.
*/
public static final int CREATED = 2;
/**
* The Blueprint extender has started destroying the Blueprint Container for
* the bundle.
*/
public static final int DESTROYING = 3;
/**
* The Blueprint Container for the bundle has been completely destroyed.
* This event is sent after the Blueprint Container has been unregistered as
* a service.
*/
public static final int DESTROYED = 4;
/**
* The Blueprint Container creation for the bundle has failed. If this event
* is sent after a timeout in the Grace Period, the
* {@link #getDependencies()} method must return an array of missing
* mandatory dependencies. The event must also contain the cause of the
* failure as a <code>Throwable</code> through the {@link #getCause()}
* method.
*/
public static final int FAILURE = 5;
/**
* The Blueprint Container has entered the grace period. The list of missing
* dependencies must be made available through the
* {@link #getDependencies()} method. During the grace period, a
* {@link #GRACE_PERIOD} event is sent each time the set of unsatisfied
* dependencies changes.
*/
public static final int GRACE_PERIOD = 6;
/**
* The Blueprint Container is waiting on the availability of a service to
* satisfy an invocation on a referenced service. The missing dependency
* must be made available through the {@link #getDependencies()} method
* which will return an array containing one filter object as a String.
*/
public static final int WAITING = 7;
/**
* Type of this event.
*
* @see #getType()
*/
private final int type;
/**
* The time when the event occurred.
*
* @see #getTimestamp()
*/
private final long timestamp;
/**
* The Blueprint bundle.
*
* @see #getBundle()
*/
private final Bundle bundle;
/**
* The Blueprint extender bundle.
*
* @see #getExtenderBundle()
*/
private final Bundle extenderBundle;
/**
* An array containing filters identifying the missing dependencies. Must
* not be <code>null</code> when the event type requires it.
*
* @see #getDependencies()
*/
private final String[] dependencies;
/**
* Cause of the failure.
*
* @see #getCause()
*/
private final Throwable cause;
/**
* Indicate if this event is a replay event or not.
*
* @see #isReplay()
*/
private final boolean replay;
/**
* Create a simple <code>BlueprintEvent</code> object.
*
* @param type The type of this event.
* @param bundle The Blueprint bundle associated with this event. This
* parameter must not be <code>null</code>.
* @param extenderBundle The Blueprint extender bundle that is generating
* this event. This parameter must not be <code>null</code>.
*/
public BlueprintEvent(int type, Bundle bundle, Bundle extenderBundle) {
this(type, bundle, extenderBundle, null, null);
}
/**
* Create a <code>BlueprintEvent</code> object associated with a set of
* dependencies.
*
* @param type The type of this event.
* @param bundle The Blueprint bundle associated with this event. This
* parameter must not be <code>null</code>.
* @param extenderBundle The Blueprint extender bundle that is generating
* this event. This parameter must not be <code>null</code>.
* @param dependencies An array of <code>String</code> filters for each
* dependency associated with this event. Must be a non-empty array
* for event types {@link #FAILURE}, {@link #GRACE_PERIOD} and
* {@link #WAITING}. Must be <code>null</code> for other event types.
*/
public BlueprintEvent(int type, Bundle bundle, Bundle extenderBundle,
String[] dependencies) {
this(type, bundle, extenderBundle, dependencies, null);
}
/**
* Create a <code>BlueprintEvent</code> object associated with a failure
* cause.
*
* @param type The type of this event.
* @param bundle The Blueprint bundle associated with this event. This
* parameter must not be <code>null</code>.
* @param extenderBundle The Blueprint extender bundle that is generating
* this event. This parameter must not be <code>null</code>.
* @param cause A <code>Throwable</code> object describing the root cause of
* the event. May be <code>null</code>.
*/
public BlueprintEvent(int type, Bundle bundle, Bundle extenderBundle,
Throwable cause) {
this(type, bundle, extenderBundle, null, cause);
}
/**
* Create a <code>BlueprintEvent</code> object associated with a failure
* cause and a set of dependencies.
*
* @param type The type of this event.
* @param bundle The Blueprint bundle associated with this event. This
* parameter must not be <code>null</code>.
* @param extenderBundle The Blueprint extender bundle that is generating
* this event. This parameter must not be <code>null</code>.
* @param dependencies An array of <code>String</code> filters for each
* dependency associated with this event. Must be a non-empty array
* for event types {@link #GRACE_PERIOD} and (@link #WAITING}. It
* is optional for {@link #FAILURE} event types.
* Must be <code>null</code> for other event types.
* @param cause A <code>Throwable</code> object describing the root cause of
* this event. May be <code>null</code>.
*/
public BlueprintEvent(int type, Bundle bundle, Bundle extenderBundle,
String[] dependencies, Throwable cause) {
this.type = type;
this.timestamp = System.currentTimeMillis();
this.bundle = bundle;
this.extenderBundle = extenderBundle;
this.dependencies = dependencies == null ? null
: (String[]) dependencies.clone();;
this.cause = cause;
this.replay = false;
if (bundle == null) {
throw new NullPointerException("bundle must not be null");
}
if (extenderBundle == null) {
throw new NullPointerException("extenderBundle must not be null");
}
switch (type) {
case WAITING :
case GRACE_PERIOD :
if (dependencies == null) {
throw new NullPointerException(
"dependencies must not be null");
}
if (dependencies.length == 0) {
throw new IllegalArgumentException(
"dependencies must not be length zero");
}
break;
case FAILURE :
// not all FAILURE events have a dependency list, but if there
// is one, it must be non-empty.
if (dependencies != null) {
if (dependencies.length == 0) {
throw new IllegalArgumentException(
"dependencies must not be length zero");
}
}
break;
default :
if (dependencies != null) {
throw new IllegalArgumentException(
"dependencies must be null");
}
break;
}
}
/**
* Create a new <code>BlueprintEvent</code> from the specified
* <code>BlueprintEvent</code>. The <code>timestamp</code> property will be
* copied from the original event and only the replay property will be
* overridden with the given value.
*
* @param event The original <code>BlueprintEvent</code> to copy. Must not
* be <code>null</code>.
* @param replay <code>true</code> if this event should be used as a replay
* event.
*/
public BlueprintEvent(BlueprintEvent event, boolean replay) {
this.type = event.type;
this.timestamp = event.timestamp;
this.bundle = event.bundle;
this.extenderBundle = event.extenderBundle;
this.dependencies = event.dependencies;
this.cause = event.cause;
this.replay = replay;
}
/**
* Return the type of this event.
* <p>
* The type values are:
* <ul>
* <li>{@link #CREATING}</li>
* <li>{@link #CREATED}</li>
* <li>{@link #DESTROYING}</li>
* <li>{@link #DESTROYED}</li>
* <li>{@link #FAILURE}</li>
* <li>{@link #GRACE_PERIOD}</li>
* <li>{@link #WAITING}</li>
* </ul>
*
* @return The type of this event.
*/
public int getType() {
return type;
}
/**
* Return the time at which this event was created.
*
* @return The time at which this event was created.
*/
public long getTimestamp() {
return timestamp;
}
/**
* Return the Blueprint bundle associated with this event.
*
* @return The Blueprint bundle associated with this event.
*/
public Bundle getBundle() {
return bundle;
}
/**
* Return the Blueprint extender bundle that is generating this event.
*
* @return The Blueprint extender bundle that is generating this event.
*/
public Bundle getExtenderBundle() {
return extenderBundle;
}
/**
* Return the filters identifying the missing dependencies that caused this
* event.
*
* @return The filters identifying the missing dependencies that caused this
* event if the event type is one of {@link #WAITING},
* {@link #GRACE_PERIOD} or {@link #FAILURE} or <code>null</code>
* for the other event types.
*/
public String[] getDependencies() {
return dependencies == null ? null : (String[]) dependencies.clone();
}
/**
* Return the cause for this {@link #FAILURE} event.
*
* @return The cause of the failure for this event. May be <code>null</code>
* .
*/
public Throwable getCause() {
return cause;
}
/**
* Return whether this event is a replay event.
*
* @return <code>true</code> if this event is a replay event and
* <code>false</code> otherwise.
*/
public boolean isReplay() {
return replay;
}
}
| 9,062 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/ComponentDefinitionException.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.container;
/**
* A Blueprint exception indicating that a component definition is in error.
*
* This exception is thrown when a configuration-related error occurs during
* creation of a Blueprint Container.
*
* @version $Revision$
*/
public class ComponentDefinitionException extends RuntimeException {
private static final long serialVersionUID = 1L;
/**
* Creates a Component Definition Exception with no message or exception
* cause.
*/
public ComponentDefinitionException() {
super();
}
/**
* Creates a Component Definition Exception with the specified message
*
* @param explanation The associated message.
*/
public ComponentDefinitionException(String explanation) {
super(explanation);
}
/**
* Creates a Component Definition Exception with the specified message and
* exception cause.
*
* @param explanation The associated message.
* @param cause The cause of this exception.
*/
public ComponentDefinitionException(String explanation, Throwable cause) {
super(explanation, cause);
}
/**
* Creates a Component Definition Exception with the exception cause.
*
* @param cause The cause of this exception.
*/
public ComponentDefinitionException(Throwable cause) {
super(cause);
}
}
| 9,063 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/EventConstants.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.container;
/**
* Event property names used in Event Admin events published by a Blueprint
* Container.
*
* <p>
* Each type of event is sent to a different topic:
*
* <p>
* <code>org/osgi/service/blueprint/container/</code><em><event-type></em>
*
* <p>
* where <em><event-type></em> can have the values
* {@link BlueprintEvent#CREATING CREATING}, {@link BlueprintEvent#CREATED
* CREATED}, {@link BlueprintEvent#DESTROYING DESTROYING},
* {@link BlueprintEvent#DESTROYED DESTROYED}, {@link BlueprintEvent#FAILURE
* FAILURE}, {@link BlueprintEvent#GRACE_PERIOD GRACE_PERIOD}, or
* {@link BlueprintEvent#WAITING WAITING}.
*
* <p>
* Such events have the following properties:
* <ul>
* <li>{@link #TYPE type}</li>
* <li>{@link #EVENT event}</li>
* <li>{@link #TIMESTAMP timestamp}</li>
* <li>{@link #BUNDLE bundle}</li>
* <li>{@link #BUNDLE_SYMBOLICNAME bundle.symbolicName}</li>
* <li>{@link #BUNDLE_ID bundle.id}</li>
* <li>{@link #BUNDLE_VERSION bundle.version}</li>
* <li>{@link #EXTENDER_BUNDLE_SYMBOLICNAME extender.bundle.symbolicName}</li>
* <li>{@link #EXTENDER_BUNDLE_ID extender.bundle.id}</li>
* <li>{@link #EXTENDER_BUNDLE_VERSION extender.bundle.version}</li>
* <li>{@link #DEPENDENCIES dependencies}</li>
* <li>{@link #CAUSE cause}</li>
* </ul>
*
* @Immutable
* @version $Revision$
*/
public class EventConstants {
private EventConstants() {
// non-instantiable class
}
/**
* The type of the event that has been issued. This property is of type
* <code>Integer</code> and can take one of the values defined in
* {@link BlueprintEvent}.
*/
public static final String TYPE = "type";
/**
* The <code>BlueprintEvent</code> object that caused this event. This
* property is of type {@link BlueprintEvent}.
*/
public static final String EVENT = "event";
/**
* The time the event was created. This property is of type
* <code>Long</code>.
*/
public static final String TIMESTAMP = "timestamp";
/**
* The Blueprint bundle associated with this event. This property is of type
* <code>Bundle</code>.
*/
public static final String BUNDLE = "bundle";
/**
* The bundle id of the Blueprint bundle associated with this event. This
* property is of type <code>Long</code>.
*/
public static final String BUNDLE_ID = "bundle.id";
/**
* The bundle symbolic name of the Blueprint bundle associated with this
* event. This property is of type <code>String</code>.
*/
public static final String BUNDLE_SYMBOLICNAME = "bundle.symbolicName";
/**
* The bundle version of the Blueprint bundle associated with this event.
* This property is of type <code>Version</code>.
*/
public static final String BUNDLE_VERSION = "bundle.version";
/**
* The Blueprint extender bundle that is generating this event. This
* property is of type <code>Bundle</code>.
*/
public static final String EXTENDER_BUNDLE = "extender.bundle";
/**
* The bundle id of the Blueprint extender bundle that is generating this
* event. This property is of type <code>Long</code>.
*/
public static final String EXTENDER_BUNDLE_ID = "extender.bundle.id";
/**
* The bundle symbolic of the Blueprint extender bundle that is generating
* this event. This property is of type <code>String</code>.
*/
public static final String EXTENDER_BUNDLE_SYMBOLICNAME = "extender.bundle.symbolicName";
/**
* The bundle version of the Blueprint extender bundle that is generating
* this event. This property is of type <code>Version</code>.
*/
public static final String EXTENDER_BUNDLE_VERSION = "extender.bundle.version";
/**
* The filters identifying the missing dependencies that caused this event
* for a {@link BlueprintEvent#FAILURE FAILURE},
* {@link BlueprintEvent#GRACE_PERIOD GRACE_PERIOD}, or
* {@link BlueprintEvent#WAITING WAITING} event. This property type is an
* array of <code>String</code>.
*/
public static final String DEPENDENCIES = "dependencies";
/**
* The cause for a {@link BlueprintEvent#FAILURE FAILURE} event. This
* property is of type <code>Throwable</code>.
*/
public static final String CAUSE = "cause";
/**
* Topic prefix for all events issued by the Blueprint Container
*/
public static final String TOPIC_BLUEPRINT_EVENTS = "org/osgi/service/blueprint/container";
/**
* Topic for Blueprint Container CREATING events
*/
public static final String TOPIC_CREATING = TOPIC_BLUEPRINT_EVENTS
+ "/CREATING";
/**
* Topic for Blueprint Container CREATED events
*/
public static final String TOPIC_CREATED = TOPIC_BLUEPRINT_EVENTS
+ "/CREATED";
/**
* Topic for Blueprint Container DESTROYING events
*/
public static final String TOPIC_DESTROYING = TOPIC_BLUEPRINT_EVENTS
+ "/DESTROYING";
/**
* Topic for Blueprint Container DESTROYED events
*/
public static final String TOPIC_DESTROYED = TOPIC_BLUEPRINT_EVENTS
+ "/DESTROYED";
/**
* Topic for Blueprint Container FAILURE events
*/
public static final String TOPIC_FAILURE = TOPIC_BLUEPRINT_EVENTS
+ "/FAILURE";
/**
* Topic for Blueprint Container GRACE_PERIOD events
*/
public static final String TOPIC_GRACE_PERIOD = TOPIC_BLUEPRINT_EVENTS
+ "/GRACE_PERIOD";
/**
* Topic for Blueprint Container WAITING events
*/
public static final String TOPIC_WAITING = TOPIC_BLUEPRINT_EVENTS
+ "/WAITING";
}
| 9,064 |
0 | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint | Create_ds/aries/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/NoSuchComponentException.java | /*
* Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
*
* Licensed 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.osgi.service.blueprint.container;
/**
* A Blueprint exception indicating that a component does not exist in a
* Blueprint Container.
*
* This exception is thrown when an attempt is made to create a component
* instance or lookup Component Metadata using a component id that does not
* exist in the Blueprint Container.
*
* @version $Revision$
*/
public class NoSuchComponentException extends RuntimeException {
private static final long serialVersionUID = 1L;
/**
* The requested component id that generated the exception.
*/
private final String componentId;
/**
* Create a No Such Component Exception for a non-existent component.
*
* @param msg The associated message.
* @param id The id of the non-existent component.
*/
public NoSuchComponentException(String msg, String id) {
super(msg);
this.componentId = id;
}
/**
* Create a No Such Component Exception for a non-existent component.
*
* @param id The id of the non-existent component.
*/
public NoSuchComponentException(String id) {
super("No component with id '" + (id == null ? "<null>" : id)
+ "' could be found");
this.componentId = id;
}
/**
* Returns the id of the non-existent component.
*
* @return The id of the non-existent component.
*/
public String getComponentId() {
return componentId;
}
}
| 9,065 |
0 | Create_ds/aries/blueprint/blueprint-authz/src/test/java/org/apache/aries/blueprint/authorization | Create_ds/aries/blueprint/blueprint-authz/src/test/java/org/apache/aries/blueprint/authorization/impl/SecurityAnnoationParserTest.java | /**
* 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.aries.blueprint.authorization.impl;
import java.lang.annotation.Annotation;
import javax.annotation.security.DenyAll;
import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import org.apache.aries.blueprint.authorization.impl.test.SecuredClass;
import org.junit.Assert;
import org.junit.Test;
public class SecurityAnnoationParserTest {
private SecurityAnotationParser annParser;
public SecurityAnnoationParserTest() {
annParser = new SecurityAnotationParser();
}
@Test
public void testIsSecured() {
Assert.assertTrue(annParser.isSecured(SecuredClass.class));
Assert.assertFalse(annParser.isSecured(Object.class));
Assert.assertFalse(annParser.isSecured(Activator.class));
}
@Test
public void testAnnotationType() throws NoSuchMethodException, SecurityException {
Assert.assertTrue(getEffective("admin") instanceof RolesAllowed);
Assert.assertTrue(getEffective("user") instanceof RolesAllowed);
Assert.assertTrue(getEffective("anon") instanceof PermitAll);
Assert.assertTrue(getEffective("closed") instanceof DenyAll);
}
@Test
public void testRoles() throws NoSuchMethodException, SecurityException {
Assert.assertArrayEquals(new String[]{"admin"}, getRoles("admin"));
Assert.assertArrayEquals(new String[]{"user"}, getRoles("user"));
}
private Annotation getEffective(String methodName) throws NoSuchMethodException {
return annParser.getEffectiveAnnotation(SecuredClass.class, SecuredClass.class.getMethod(methodName));
}
private String[] getRoles(String methodName) throws NoSuchMethodException {
Annotation ann = getEffective(methodName);
Assert.assertTrue(ann instanceof RolesAllowed);
return ((RolesAllowed)ann).value();
}
}
| 9,066 |
0 | Create_ds/aries/blueprint/blueprint-authz/src/test/java/org/apache/aries/blueprint/authorization/impl | Create_ds/aries/blueprint/blueprint-authz/src/test/java/org/apache/aries/blueprint/authorization/impl/test/SecuredClass.java | /**
* 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.aries.blueprint.authorization.impl.test;
import javax.annotation.security.DenyAll;
import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
@RolesAllowed("admin")
public class SecuredClass {
public void admin() {
}
@RolesAllowed("user")
public void user() {
}
@PermitAll
public void anon() {
}
@DenyAll
public void closed() {
}
}
| 9,067 |
0 | Create_ds/aries/blueprint/blueprint-authz/src/main/java/org/apache/aries/blueprint/authorization | Create_ds/aries/blueprint/blueprint-authz/src/main/java/org/apache/aries/blueprint/authorization/impl/SecurityAnotationParser.java | /**
* 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.aries.blueprint.authorization.impl;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method;
import javax.annotation.security.DenyAll;
import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
/**
* Evaluates JEE security annotations
* @see PermitAll
* @see DenyAll
* @see RolesAllowed
*/
class SecurityAnotationParser {
/**
* Get the effective annotation regarding method annotations override class annotations.
* DenyAll has highest priority then RolesAllowed and in the end PermitAll.
* So the most restrictive annotation is preferred.
*
* @param m Method to check
* @return effective annotation (either DenyAll, PermitAll or RolesAllowed)
*/
Annotation getEffectiveAnnotation(Class<?> beanClass, Method m) {
Annotation classLevel = getAuthAnnotation(beanClass);
try {
Method beanMethod = beanClass.getMethod(m.getName(), m.getParameterTypes());
Annotation methodLevel = getAuthAnnotation(beanMethod);
return (methodLevel != null) ? methodLevel : classLevel;
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
private Annotation getAuthAnnotation(AnnotatedElement element) {
Annotation ann = null;
ann = element.getAnnotation(DenyAll.class);
if (ann == null) {
ann = element.getAnnotation(RolesAllowed.class);
}
if (ann == null) {
ann = element.getAnnotation(PermitAll.class);
}
return ann;
}
/**
* A class is secured if either the class or one of its methods is secured.
* An AnnotatedElement is secured if @RolesAllowed or @DenyAll is present.
*
* @param clazz
* @return
*/
public boolean isSecured(Class<?> clazz) {
if (clazz == Object.class) {
return false;
}
if (isSecuredEl(clazz)) {
return true;
}
for (Method m : clazz.getMethods()) {
if (isSecuredEl(m)) {
return true;
}
}
return false;
}
private boolean isSecuredEl(AnnotatedElement element) {
return element.isAnnotationPresent(RolesAllowed.class) || element.isAnnotationPresent(DenyAll.class);
}
}
| 9,068 |
0 | Create_ds/aries/blueprint/blueprint-authz/src/main/java/org/apache/aries/blueprint/authorization | Create_ds/aries/blueprint/blueprint-authz/src/main/java/org/apache/aries/blueprint/authorization/impl/AuthorizationNsHandler.java | /*
* 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.aries.blueprint.authorization.impl;
import java.net.URL;
import java.util.Collections;
import java.util.Set;
import org.apache.aries.blueprint.ComponentDefinitionRegistry;
import org.apache.aries.blueprint.NamespaceHandler;
import org.apache.aries.blueprint.ParserContext;
import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
import org.apache.aries.blueprint.mutable.MutablePassThroughMetadata;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
import org.osgi.service.blueprint.reflect.Metadata;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class AuthorizationNsHandler implements NamespaceHandler {
private static final String NS_AUTHZ = "http://aries.apache.org/xmlns/authorization/v1.0.0";
private void parseElement(Element elt, ComponentMetadata cm, ParserContext pc) {
ComponentDefinitionRegistry cdr = pc.getComponentDefinitionRegistry();
if ("enable".equals(elt.getLocalName()) && NS_AUTHZ.equals(elt.getNamespaceURI())
&& !cdr.containsComponentDefinition(AuthorizationBeanProcessor.AUTH_PROCESSOR_BEAN_NAME)) {
cdr.registerComponentDefinition(authBeanProcessor(pc, cdr));
}
}
private MutableBeanMetadata authBeanProcessor(ParserContext pc, ComponentDefinitionRegistry cdr) {
MutableBeanMetadata meta = pc.createMetadata(MutableBeanMetadata.class);
meta.setId(AuthorizationBeanProcessor.AUTH_PROCESSOR_BEAN_NAME);
meta.setRuntimeClass(AuthorizationBeanProcessor.class);
meta.setProcessor(true);
meta.addProperty("cdr", passThrough(pc, cdr));
return meta;
}
private MutablePassThroughMetadata passThrough(ParserContext pc, Object o) {
MutablePassThroughMetadata meta = pc.createMetadata(MutablePassThroughMetadata.class);
meta.setObject(o);
return meta;
}
public ComponentMetadata decorate(Node node, ComponentMetadata cm, ParserContext pc) {
if (node instanceof Element) {
parseElement((Element)node, cm, pc);
}
return cm;
}
public Metadata parse(Element elt, ParserContext pc) {
parseElement(elt, pc.getEnclosingComponent(), pc);
return null;
}
public URL getSchemaLocation(String namespace) {
if (NS_AUTHZ.equals(namespace)) {
return this.getClass().getResource("/authz10.xsd");
} else {
return null;
}
}
@SuppressWarnings("rawtypes")
public Set<Class> getManagedClasses() {
return Collections.emptySet();
}
}
| 9,069 |
0 | Create_ds/aries/blueprint/blueprint-authz/src/main/java/org/apache/aries/blueprint/authorization | Create_ds/aries/blueprint/blueprint-authz/src/main/java/org/apache/aries/blueprint/authorization/impl/AuthorizationInterceptor.java | /*
* 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.aries.blueprint.authorization.impl;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.security.AccessControlContext;
import java.security.AccessControlException;
import java.security.AccessController;
import java.security.Principal;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import javax.security.auth.Subject;
import org.apache.aries.blueprint.Interceptor;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AuthorizationInterceptor implements Interceptor {
private static final Logger LOGGER = LoggerFactory.getLogger(AuthorizationInterceptor.class);
private Class<?> beanClass;
public AuthorizationInterceptor(Class<?> beanClass) {
this.beanClass = beanClass;
}
public int getRank() {
return 0;
}
public void postCallWithException(ComponentMetadata cm, Method m, Throwable ex, Object preCallToken) {
}
public void postCallWithReturn(ComponentMetadata cm, Method m, Object returnType, Object preCallToken)
throws Exception {
}
public Object preCall(ComponentMetadata cm, Method m, Object... parameters) throws Throwable {
Annotation ann = new SecurityAnotationParser().getEffectiveAnnotation(beanClass, m);
if (ann instanceof PermitAll) {
return null;
}
String[] rolesAr = new String[] {}; // Also applies for @DenyAll
if (ann instanceof RolesAllowed) {
rolesAr = ((RolesAllowed) ann).value();
}
Set<String> roles = new HashSet<String>(Arrays.asList(rolesAr));
AccessControlContext acc = AccessController.getContext();
Subject subject = Subject.getSubject(acc);
if (subject == null) {
throw new AccessControlException("Method call " + m.getDeclaringClass() + "." + m.getName() + " denied. No JAAS login present");
}
Set<Principal> principals = subject.getPrincipals();
for (Principal principal : principals) {
if (roles.contains(principal.getName())) {
LOGGER.debug("Granting access to Method: {} for {}.", m, principal);
return null;
}
}
String msg = String.format("Method call %s.%s denied. Roles allowed are %s. Your principals are %s.",
m.getDeclaringClass(), m.getName(), roles, getNames(principals));
throw new AccessControlException(msg);
}
private String getNames(Set<Principal> principals) {
StringBuilder sb = new StringBuilder();
for (Principal principal : principals) {
sb.append(principal.getName() + " ");
}
return sb.toString();
}
}
| 9,070 |
0 | Create_ds/aries/blueprint/blueprint-authz/src/main/java/org/apache/aries/blueprint/authorization | Create_ds/aries/blueprint/blueprint-authz/src/main/java/org/apache/aries/blueprint/authorization/impl/AuthorizationBeanProcessor.java | /**
* 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.aries.blueprint.authorization.impl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.aries.blueprint.BeanProcessor;
import org.apache.aries.blueprint.ComponentDefinitionRegistry;
import org.apache.aries.blueprint.Processor;
import org.osgi.service.blueprint.reflect.BeanMetadata;
public class AuthorizationBeanProcessor implements BeanProcessor {
private static final Logger LOGGER = LoggerFactory.getLogger(AuthorizationInterceptor.class);
public static final String AUTH_PROCESSOR_BEAN_NAME = "org_apache_aries_authz_annotations";
private ComponentDefinitionRegistry cdr;
public AuthorizationBeanProcessor() {
}
public void setCdr(ComponentDefinitionRegistry cdr) {
this.cdr = cdr;
}
public void afterDestroy(Object arg0, String arg1) {
}
public Object afterInit(Object bean, String beanName, BeanCreator beanCreator, BeanMetadata beanData) {
return bean;
}
public void beforeDestroy(Object arg0, String arg1) {
}
public Object beforeInit(Object bean, String beanName, BeanCreator beanCreator, BeanMetadata beanData) {
if (bean instanceof Processor) {
// Never enhance other processors
return bean;
}
Class<?> c = bean.getClass();
if (new SecurityAnotationParser().isSecured(c)) {
LOGGER.debug("Adding annotation based authorization interceptor for bean {} with class {}", beanName, c);
cdr.registerInterceptorWithComponent(beanData, new AuthorizationInterceptor(bean.getClass()));
}
return bean;
}
}
| 9,071 |
0 | Create_ds/aries/blueprint/blueprint-authz/src/main/java/org/apache/aries/blueprint/authorization | Create_ds/aries/blueprint/blueprint-authz/src/main/java/org/apache/aries/blueprint/authorization/impl/Activator.java | /**
* 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.aries.blueprint.authorization.impl;
import java.util.Dictionary;
import java.util.Hashtable;
import org.apache.aries.blueprint.NamespaceHandler;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator {
@Override
public void start(BundleContext context) throws Exception {
AuthorizationNsHandler handler = new AuthorizationNsHandler();
Dictionary<String, String> props = new Hashtable<String, String>();
props.put("osgi.service.blueprint.namespace", "http://aries.apache.org/xmlns/authorization/v1.0.0");
context.registerService(NamespaceHandler.class, handler, props);
}
@Override
public void stop(BundleContext context) throws Exception {
}
}
| 9,072 |
0 | Create_ds/aries/blueprint/blueprint-jexl-evaluator/src/main/java/org/apache/aries/blueprint/jexl | Create_ds/aries/blueprint/blueprint-jexl-evaluator/src/main/java/org/apache/aries/blueprint/jexl/evaluator/JexlPropertyEvaluator.java | /**
* 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.aries.blueprint.jexl.evaluator;
import java.util.*;
import org.apache.aries.blueprint.ext.evaluator.PropertyEvaluatorExt;
import org.apache.commons.jexl2.Expression;
import org.apache.commons.jexl2.JexlEngine;
import org.apache.commons.jexl2.MapContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class JexlPropertyEvaluator implements PropertyEvaluatorExt {
private static final Logger LOGGER = LoggerFactory.getLogger(JexlPropertyEvaluator.class);
public Object evaluate(String expression, Map<String, Object> properties) {
try {
JexlEngine engine = new JexlEngine();
MapContext context = new MapContext(properties);
Expression exp = engine.createExpression(expression);
return exp.evaluate(context);
} catch (Exception e) {
LOGGER.info("Could not evaluate expression: {}", expression);
LOGGER.info("Exception:", e);
return null;
}
}
}
| 9,073 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundles/src/main/java/org/apache/aries/blueprint | Create_ds/aries/blueprint/itests/blueprint-testbundles/src/main/java/org/apache/aries/blueprint/testbundles/BeanA.java | /**
* 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.aries.blueprint.testbundles;
public class BeanA {
public BeanA(String arg1) {
}
}
| 9,074 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundles/src/main/java/org/apache/aries/blueprint | Create_ds/aries/blueprint/itests/blueprint-testbundles/src/main/java/org/apache/aries/blueprint/testbundles/BeanCItf.java | /*
* 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.aries.blueprint.testbundles;
public interface BeanCItf {
void doSomething();
int getInitialized();
}
| 9,075 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundles/src/main/java/org/apache/aries/blueprint | Create_ds/aries/blueprint/itests/blueprint-testbundles/src/main/java/org/apache/aries/blueprint/testbundles/BeanAFactory.java | /**
* 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.aries.blueprint.testbundles;
public class BeanAFactory {
public static BeanA createBean(String arg1) {
return new BeanA(arg1);
}
}
| 9,076 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundles/src/main/java/org/apache/aries/blueprint | Create_ds/aries/blueprint/itests/blueprint-testbundles/src/main/java/org/apache/aries/blueprint/testbundles/BeanB.java | /**
* 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.aries.blueprint.testbundles;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
public class BeanB implements ApplicationContextAware {
private BeanA beanA;
private ApplicationContext applicationContext;
public BeanA getBeanA() {
return beanA;
}
public void setBeanA(BeanA beanA) {
this.beanA = beanA;
}
public ApplicationContext getApplicationContext() {
return applicationContext;
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
}
| 9,077 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundles/src/main/java/org/apache/aries/blueprint | Create_ds/aries/blueprint/itests/blueprint-testbundles/src/main/java/org/apache/aries/blueprint/testbundles/BeanC.java | /**
* 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.aries.blueprint.testbundles;
import javax.annotation.PostConstruct;
import org.springframework.transaction.annotation.Transactional;
public class BeanC implements BeanCItf {
private final BeanA beanA;
private int initialized;
public BeanC(BeanA beanA) {
this.beanA = beanA;
}
@PostConstruct
public void start() {
this.initialized++;
}
@Transactional
public void doSomething() {
}
public int getInitialized() {
return initialized;
}
}
| 9,078 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea/InterfaceWithDependency.java | /**
* 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.aries.blueprint.testbundlea;
import org.apache.aries.blueprint.testbundlea.dependency.Dependency;
public interface InterfaceWithDependency {
public void doSomething(Dependency dep);
}
| 9,079 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea/ProcessableBean.java | /**
* 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.aries.blueprint.testbundlea;
import java.util.List;
import org.apache.aries.blueprint.BeanProcessor;
/**
* Simple little interface to allow testing of BeanProcessors.
*/
public interface ProcessableBean {
public enum Phase {BEFORE_INIT, AFTER_INIT, BEFORE_DESTROY, AFTER_DESTROY};
List<BeanProcessor> getProcessedBy();
List<BeanProcessor> getProcessedBy(Phase p);
void processBeforeInit(BeanProcessor bp);
void processAfterInit(BeanProcessor bp);
void processBeforeDestroy(BeanProcessor bp);
void processAfterDestroy(BeanProcessor bp);
}
| 9,080 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea/BeanProcessorTest.java | /**
* 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.aries.blueprint.testbundlea;
import org.apache.aries.blueprint.BeanProcessor;
import org.osgi.service.blueprint.reflect.BeanMetadata;
public class BeanProcessorTest implements BeanProcessor {
public Object beforeInit(Object bean, String beanName,
BeanCreator beanCreator, BeanMetadata beanData) {
if(bean instanceof ProcessableBean){
ProcessableBean pb = (ProcessableBean)bean;
pb.processBeforeInit(this);
}
return bean;
}
public Object afterInit(Object bean, String beanName,
BeanCreator beanCreator, BeanMetadata beanData) {
if(bean instanceof ProcessableBean){
((ProcessableBean)bean).processAfterInit(this);
}
return bean;
}
public void beforeDestroy(Object bean, String beanName) {
if(bean instanceof ProcessableBean){
((ProcessableBean)bean).processBeforeDestroy(this);
}
}
public void afterDestroy(Object bean, String beanName) {
if(bean instanceof ProcessableBean){
((ProcessableBean)bean).processAfterDestroy(this);
}
}
} | 9,081 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea/NSHandlerSeven.java | /**
* 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.aries.blueprint.testbundlea;
import java.net.URL;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.apache.aries.blueprint.NamespaceHandler;
import org.apache.aries.blueprint.ParserContext;
import org.apache.aries.blueprint.PassThroughMetadata;
import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
import org.apache.aries.blueprint.mutable.MutableRefMetadata;
import org.osgi.service.blueprint.reflect.BeanMetadata;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
import org.osgi.service.blueprint.reflect.Metadata;
import org.osgi.service.blueprint.reflect.RefMetadata;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class NSHandlerSeven implements NamespaceHandler{
public static String NSURI = "http://ns.handler.seven";
private static String ELT_NAME = "nshandlerseven";
private static String ATTRIB_ID = "id";
//process elements
public Metadata parse(Element element, ParserContext context) {
Metadata retval = null;
if( element.getLocalName().equals(ELT_NAME) ) {
final String id = element.getAttributeNS(NSURI, ATTRIB_ID);
MutableBeanMetadata bm = context.createMetadata(MutableBeanMetadata.class);
bm.setId(id);
bm.setScope("PROTOTYPE");
bm.setClassName(TestBean.class.getName());
retval = bm;
}
return retval;
}
//supply schema back to blueprint.
public URL getSchemaLocation(String namespace) {
if (NSURI.equals(namespace)) {
return this.getClass().getResource("nshandlerseven.xsd");
}
return null;
}
public Set<Class> getManagedClasses() {
Class cls = TestBean.class;
return Collections.singleton(cls);
}
public ComponentMetadata decorate(Node node, ComponentMetadata component,
ParserContext context) {
return component;
}
}
| 9,082 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea/NSHandlerOne.java | /**
* 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.aries.blueprint.testbundlea;
import java.net.URL;
import java.util.List;
import java.util.Set;
import org.apache.aries.blueprint.NamespaceHandler;
import org.apache.aries.blueprint.ParserContext;
import org.apache.aries.blueprint.PassThroughMetadata;
import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
import org.apache.aries.blueprint.mutable.MutableRefMetadata;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
import org.osgi.service.blueprint.reflect.Metadata;
import org.osgi.service.blueprint.reflect.RefMetadata;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
/**
* A simple example namespace handler, that understands an element, and 2 attributes
*
* When the element is encountered in a top level blueprint element, the handler will add a
* passthroughmetadata with it's id as the contained attribone.
* The passthroughmetadata will return a string with the value from the contained
* attrib two.
*
* If the element is encountered during processing of a bean, it will add a property to the
* bean with the name of the attribone value, and a value of the passthroughmetadata with id
* matching attribtwo
*
* This handler is designed to exercise aspects of the NamespaceHandler capability set.
*
*/
public class NSHandlerOne implements NamespaceHandler {
public static String NSURI = "http://ns.handler.one";
private static String ELT_NAME = "nshandlerone";
private static String ATTRIB_ONE = "attribone";
private static String ATTRIB_TWO = "attribtwo";
//process attributes
public ComponentMetadata decorate(Node node, ComponentMetadata component,
ParserContext context) {
//this test makes use of the 'Mutable' implementations
//without which the code would need to implement our own BeanMetadata,
//and RefMetadata.
if(component !=null && component instanceof MutableBeanMetadata){
MutableBeanMetadata mbm = (MutableBeanMetadata)component;
Attr a = (Attr)node;
Element bean = a.getOwnerElement();
String propname = bean.getAttributeNS(NSURI,ATTRIB_ONE);
//if this were not a test, we might attempt to ensure this ref existed
String passthruref = bean.getAttributeNS(NSURI,ATTRIB_TWO);
MutableRefMetadata ref = (MutableRefMetadata)context.createMetadata(RefMetadata.class);
ref.setComponentId(passthruref);
mbm.addProperty(propname, ref);
}
return component;
}
//process elements
public Metadata parse(Element element, ParserContext context) {
Metadata retval = null;
if( element.getLocalName().equals(ELT_NAME) ) {
final String id = element.getAttributeNS(NSURI,ATTRIB_ONE);
final String value = element.getAttributeNS(NSURI,ATTRIB_TWO);
PassThroughMetadata ptm = new PassThroughMetadata() {
public String getId() {
return id;
}
//not used currently
public List<String> getDependsOn() {
return null;
}
//also not used currently
public int getActivation() {
return 0;
}
public Object getObject() {
return value;
}
};
retval = ptm;
}
return retval;
}
//supply schema back to blueprint.
public URL getSchemaLocation(String namespace) {
return this.getClass().getResource("nshandlerone.xsd");
}
public Set<Class> getManagedClasses() {
return null;
}
}
| 9,083 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea/NSHandlerFour.java | /**
* 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.aries.blueprint.testbundlea;
import java.net.URL;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.apache.aries.blueprint.NamespaceHandler;
import org.apache.aries.blueprint.ParserContext;
import org.apache.aries.blueprint.PassThroughMetadata;
import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
import org.apache.aries.blueprint.mutable.MutableRefMetadata;
import org.osgi.service.blueprint.reflect.BeanMetadata;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
import org.osgi.service.blueprint.reflect.Metadata;
import org.osgi.service.blueprint.reflect.RefMetadata;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class NSHandlerFour implements NamespaceHandler{
public static String NSURI = "http://ns.handler.four";
private static String ELT_NAME = "nshandlerfour";
private static String ATTRIB_ID = "id";
//process elements
public Metadata parse(Element element, ParserContext context) {
Metadata retval = null;
if( element.getLocalName().equals(ELT_NAME) ) {
final String id = element.getAttributeNS(NSURI, ATTRIB_ID);
MutableBeanMetadata bm = context.createMetadata(MutableBeanMetadata.class);
bm.setId(id);
bm.setScope("PROTOTYPE");
bm.setClassName(TestBean.class.getName());
retval = bm;
}
return retval;
}
//supply schema back to blueprint.
public URL getSchemaLocation(String namespace) {
return this.getClass().getResource("nshandlerfour.xsd");
}
public Set<Class> getManagedClasses() {
Class cls = TestBean.class;
return Collections.singleton(cls);
}
public ComponentMetadata decorate(Node node, ComponentMetadata component,
ParserContext context) {
return component;
}
}
| 9,084 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea/TestBean.java | /**
* 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.aries.blueprint.testbundlea;
public class TestBean {
public TestBean() {
}
}
| 9,085 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea/Activator.java | /**
* 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.aries.blueprint.testbundlea;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator {
public void start(BundleContext context) {
}
public void stop(BundleContext context) {
}
}
| 9,086 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea/NSHandlerFive.java | /**
* 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.aries.blueprint.testbundlea;
import java.net.URL;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.apache.aries.blueprint.NamespaceHandler;
import org.apache.aries.blueprint.ParserContext;
import org.apache.aries.blueprint.PassThroughMetadata;
import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
import org.apache.aries.blueprint.mutable.MutableRefMetadata;
import org.osgi.service.blueprint.reflect.BeanMetadata;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
import org.osgi.service.blueprint.reflect.Metadata;
import org.osgi.service.blueprint.reflect.RefMetadata;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class NSHandlerFive implements NamespaceHandler{
public static String NSURI = "http://ns.handler.five";
private static String ELT_NAME = "nshandlerfive";
private static String ATTRIB_ID = "id";
//process elements
public Metadata parse(Element element, ParserContext context) {
Metadata retval = null;
if( element.getLocalName().equals(ELT_NAME) ) {
final String id = element.getAttributeNS(NSURI, ATTRIB_ID);
MutableBeanMetadata bm = context.createMetadata(MutableBeanMetadata.class);
bm.setId(id);
bm.setScope("PROTOTYPE");
bm.setClassName(TestBean.class.getName());
retval = bm;
}
return retval;
}
//supply schema back to blueprint.
public URL getSchemaLocation(String namespace) {
System.out.println("Schemans: " + namespace);
if (NSURI.equals(namespace)) {
return this.getClass().getResource("nshandlerfive.xsd");
}
return this.getClass().getResource("nshandlerfiveimport.xsd");
}
public Set<Class> getManagedClasses() {
Class cls = TestBean.class;
return Collections.singleton(cls);
}
public ComponentMetadata decorate(Node node, ComponentMetadata component,
ParserContext context) {
return component;
}
}
| 9,087 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea/NSHandlerTwo.java | /**
* 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.aries.blueprint.testbundlea;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.apache.aries.blueprint.Interceptor;
import org.apache.aries.blueprint.NamespaceHandler;
import org.apache.aries.blueprint.ParserContext;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
import org.osgi.service.blueprint.reflect.Metadata;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
/**
* A simple example namespace handler, that understands an element, and 2 attributes
*
* When attribone is found on a bean, an interceptor is added that will track invocations.
*
* This handler is designed to exercise aspects of the NamespaceHandler capability set.
*
*/
public class NSHandlerTwo implements NamespaceHandler{
public static String NSURI = "http://ns.handler.two";
private static String ELT_NAME = "nshandlertwo";
private static String ATTRIB_ONE = "attribone";
private static String ATTRIB_TWO = "attribtwo";
private static List<String> interceptorLog = new ArrayList<String>();
private static Interceptor tracker = new Interceptor() {
//debug/trace calls to toString etc will mess up the interceptor
//log, and break tests if tracked. So we filter them out here.
private boolean isIgnorableMethod(Method m){
if(m.getDeclaringClass()==Object.class){
return true;
}
else
return false;
}
public Object preCall(ComponentMetadata cm, Method m, Object... parameters)
throws Throwable {
String args = "[";
if(parameters!=null){
if(parameters.length>0){
args+=parameters[0]==null ? "null" : parameters[0].toString();
}
for(int index=1; index<parameters.length; index++){
args+=","+(parameters[index]==null ? "null" : parameters[index].toString());
}
}
args+="]";
String token = cm.getId() +":"+ m.getName() +":"+args+":"+System.currentTimeMillis();
if(!isIgnorableMethod(m))
interceptorLog.add("PRECALL:"+token);
return token;
}
public void postCallWithReturn(ComponentMetadata cm, Method m,
Object returnType, Object preCallToken) throws Throwable {
if(!isIgnorableMethod(m))
interceptorLog.add("POSTCALL["+returnType.toString()+"]:"+preCallToken);
}
public void postCallWithException(ComponentMetadata cm, Method m,
Throwable ex, Object preCallToken) throws Throwable {
if(!isIgnorableMethod(m))
interceptorLog.add("POSTCALLEXCEPTION["+ex.toString()+"]:"+preCallToken);
}
public int getRank() {
return 0;
}
};
//
public ComponentMetadata decorate(Node node, ComponentMetadata component,
ParserContext context) {
if(node.getLocalName().equals(ATTRIB_ONE)){
if(context.getComponentDefinitionRegistry().getInterceptors(component) == null ||
!context.getComponentDefinitionRegistry().getInterceptors(component).contains(tracker) ){
context.getComponentDefinitionRegistry().registerInterceptorWithComponent(component, tracker);
}
}
return component;
}
//process elements
public Metadata parse(Element element, ParserContext context) {
return null;
}
//supply schema back to blueprint.
public URL getSchemaLocation(String namespace) {
return this.getClass().getResource("nshandlertwo.xsd");
}
public Set<Class> getManagedClasses() {
return null;
}
public List<String> getLog() {
return Collections.unmodifiableList(interceptorLog);
}
}
| 9,088 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea/NSHandlerHeight.java | /**
* 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.aries.blueprint.testbundlea;
import java.net.URL;
import java.util.Collections;
import java.util.Set;
import org.apache.aries.blueprint.NamespaceHandler;
import org.apache.aries.blueprint.ParserContext;
import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
import org.osgi.service.blueprint.reflect.Metadata;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class NSHandlerHeight implements NamespaceHandler{
public static String NSURI = "http://ns.handler.height";
private static String ELT_NAME = "nshandlerheight";
private static String ATTRIB_ID = "id";
//process elements
public Metadata parse(Element element, ParserContext context) {
Metadata retval = null;
if( element.getLocalName().equals(ELT_NAME) ) {
final String id = element.getAttributeNS(NSURI, ATTRIB_ID);
MutableBeanMetadata bm = context.createMetadata(MutableBeanMetadata.class);
bm.setId(id);
bm.setScope("PROTOTYPE");
bm.setClassName(TestBean.class.getName());
retval = bm;
}
return retval;
}
//supply schema back to blueprint.
public URL getSchemaLocation(String namespace) {
if (NSURI.equals(namespace)) {
return this.getClass().getResource("nshandlerheight.xsd");
}
return null;
}
public Set<Class> getManagedClasses() {
Class cls = TestBean.class;
return Collections.singleton(cls);
}
public ComponentMetadata decorate(Node node, ComponentMetadata component,
ParserContext context) {
return component;
}
}
| 9,089 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea/NSHandlerSix.java | /**
* 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.aries.blueprint.testbundlea;
import java.net.URL;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.apache.aries.blueprint.NamespaceHandler;
import org.apache.aries.blueprint.ParserContext;
import org.apache.aries.blueprint.PassThroughMetadata;
import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
import org.apache.aries.blueprint.mutable.MutableRefMetadata;
import org.osgi.service.blueprint.reflect.BeanMetadata;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
import org.osgi.service.blueprint.reflect.Metadata;
import org.osgi.service.blueprint.reflect.RefMetadata;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class NSHandlerSix implements NamespaceHandler{
public static String NSURI = "http://ns.handler.six";
private static String ELT_NAME = "nshandlersix";
private static String ATTRIB_ID = "id";
//process elements
public Metadata parse(Element element, ParserContext context) {
Metadata retval = null;
if( element.getLocalName().equals(ELT_NAME) ) {
final String id = element.getAttributeNS(NSURI, ATTRIB_ID);
MutableBeanMetadata bm = context.createMetadata(MutableBeanMetadata.class);
bm.setId(id);
bm.setScope("PROTOTYPE");
bm.setClassName(TestBean.class.getName());
retval = bm;
}
return retval;
}
//supply schema back to blueprint.
public URL getSchemaLocation(String namespace) {
if (NSURI.equals(namespace)) {
return this.getClass().getResource("nshandlersix.xsd");
}
return this.getClass().getResource("nshandlersiximport.xsd");
}
public Set<Class> getManagedClasses() {
Class cls = TestBean.class;
return Collections.singleton(cls);
}
public ComponentMetadata decorate(Node node, ComponentMetadata component,
ParserContext context) {
return component;
}
}
| 9,090 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea/NSHandlerThree.java | /**
* 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.aries.blueprint.testbundlea;
import java.net.URL;
import java.util.Set;
import org.apache.aries.blueprint.NamespaceHandler;
import org.apache.aries.blueprint.ParserContext;
import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
import org.osgi.service.blueprint.reflect.BeanMetadata;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
import org.osgi.service.blueprint.reflect.Metadata;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class NSHandlerThree implements NamespaceHandler{
public static String NSURI = "http://ns.handler.three";
private static String ELT_NAME = "nshandlerthree";
private static String ATTRIB_ONE = "attribone";
private static String ATTRIB_TWO = "attribtwo";
public ComponentMetadata decorate(Node node, ComponentMetadata component,
ParserContext context) {
if(node.getLocalName().equals(ATTRIB_ONE)){
if(component instanceof BeanMetadata){
if(context.getComponentDefinitionRegistry().getComponentDefinition(NSURI+"/BeanProcessor")==null){
BeanMetadata bm = context.createMetadata(BeanMetadata.class);
MutableBeanMetadata mbm = (MutableBeanMetadata)bm;
mbm.setProcessor(true);
mbm.setRuntimeClass(BeanProcessorTest.class);
mbm.setScope(BeanMetadata.SCOPE_SINGLETON);
mbm.setId(NSURI+"/BeanProcessor");
context.getComponentDefinitionRegistry().registerComponentDefinition(mbm);
}
}
}
return component;
}
//process elements
public Metadata parse(Element element, ParserContext context) {
return null;
}
//supply schema back to blueprint.
public URL getSchemaLocation(String namespace) {
return this.getClass().getResource("nshandlerthree.xsd");
}
public Set<Class> getManagedClasses() {
return null;
}
}
| 9,091 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea/multi/InterfaceA.java | /**
* 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.aries.blueprint.testbundlea.multi;
/**
*
*/
public interface InterfaceA {
String methodA();
}
| 9,092 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea/multi/InterfaceD.java | /**
* 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.aries.blueprint.testbundlea.multi;
public interface InterfaceD {
String methodD();
}
| 9,093 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea/multi/InterfaceB.java | /**
* 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.aries.blueprint.testbundlea.multi;
public interface InterfaceB {
String methodB();
}
| 9,094 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea/multi/MultiService.java | /**
* 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.aries.blueprint.testbundlea.multi;
/**
*
*/
public class MultiService implements InterfaceA, InterfaceB, InterfaceC, InterfaceD {
/** {@inheritDoc}*/
public String methodC() {
return "C";
}
/** {@inheritDoc}*/
public String methodB() {
return "B";
}
/** {@inheritDoc}*/
public String methodA() {
return "A";
}
/** {@inheritDoc}*/
public String methodD() {
return "D";
}
}
| 9,095 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea/multi/InterfaceC.java | /**
* 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.aries.blueprint.testbundlea.multi;
public interface InterfaceC {
String methodC();
}
| 9,096 |
0 | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea | Create_ds/aries/blueprint/itests/blueprint-testbundlea/src/main/java/org/apache/aries/blueprint/testbundlea/dependency/Dependency.java | /**
* 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.aries.blueprint.testbundlea.dependency;
public interface Dependency {
}
| 9,097 |
0 | Create_ds/aries/blueprint/itests/blueprint-testquiescebundle/src/main/java/org/apache/aries/blueprint | Create_ds/aries/blueprint/itests/blueprint-testquiescebundle/src/main/java/org/apache/aries/blueprint/testquiescebundle/TestBean.java | /**
* 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.aries.blueprint.testquiescebundle;
public class TestBean
{
public void sleep(int time) throws InterruptedException
{
Thread.sleep(time);
}
}
| 9,098 |
0 | Create_ds/aries/blueprint/itests/blueprint-testquiescebundle/src/main/java/org/apache/aries/blueprint | Create_ds/aries/blueprint/itests/blueprint-testquiescebundle/src/main/java/org/apache/aries/blueprint/testquiescebundle/Activator.java | /**
* 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.aries.blueprint.testquiescebundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator {
public void start(BundleContext context) {
}
public void stop(BundleContext context) {
}
}
| 9,099 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.